# Welcome to 1DEX

## **Our Vision**<br>

1DEX is a decentralized exchange committed to redefining finance and reshaping trust and freedom. With security, reliability, openness, and transparency as our foundation, we aim to create a next-generation platform that empowers users and fosters a vibrant, community-driven DeFi ecosystem.

## **Our Innovations and Breakthroughs**<br>

By integrating blockchain technology with PassKey authentication, we ensure unparalleled asset safety, while millisecond transaction speeds and high throughput deliver a seamless experience. Embracing openness, 1DEX offers free token listings, fully open-source smart contracts, and comprehensive SDKs/APIs, enabling developers and users to co-create a transparent, limitless DeFi future together.

<br>


# Technical Architecture Diagram

1DEX is a high-performance decentralized exchange built on an advanced technical architecture, designed to provide users with a secure, efficient, transparent, and open trading experience. Our architecture encompasses user interfaces, access authentication, development support, decentralized governance, privacy protection, and a shared order book, ensuring comprehensive optimization in performance, security, and user experience.<br>

<figure><img src="/files/s4NsBvtLEuxaHjBBmWaG" alt=""><figcaption></figcaption></figure>


# 1. User Interface

The user interface serves as the entry point for interaction with 1DEX, supporting multi-platform access to ensure users can conveniently use our services anytime, anywhere:

* **Multi-Device Support:** Includes Web, mobile (iOS/Android), and more, allowing users to access via browsers, mobile apps, or third-party integrations (e.g., Telegram).
* **Feature-Rich:** Offers an intuitive trading interface, asset management dashboard, and real-time notifications, enabling efficient operations for users.
* **Developer-Friendly:** Through open function call interfaces (e.g., func()), developers can easily integrate 1DEX services, expanding application scenarios.


# 2. Access

1DEX employs advanced access authentication mechanisms to ensure asset security while providing a seamless login experience:

## Passwordless Experience

* **OAuth Authentication:** Supports quick login via third-party accounts like Google and Apple, lowering the barrier to entry for users.
* **PassKey Authentication:** Using PassKey technology, users can authenticate their identity via biometrics (e.g., fingerprint or facial recognition) without traditional passwords. PassKey combines cryptography and device binding to prevent phishing attacks and ensure private key security.
* **Application Scenarios:** For key operations like depositing funds, placing/canceling trade orders, and withdrawing assets, users must verify their identity via PassKey to complete on-chain signature transactions, ensuring the security of each step.\ <br>

## Various Assets Support

Supports a wide range of mainstream blockchain assets (e.g., BTC, ETH, USDT), with smart contracts enabling transparent on-chain asset management and verification.


# 3. Development

1DEX provides comprehensive development tools and interfaces, empowering developers to contribute to the ecosystem and unlock the limitless potential of DeFi:

* **1DEX Web SDK:** Offers a convenient software development kit for Web developers, enabling seamless integration of 1DEX trading features.
* **Golang/Python SDK:** Supports backend development with efficient interfaces, catering to developers with diverse tech stacks.
* **Query Service:** Provides real-time on-chain data querying capabilities, allowing developers to easily access transaction and asset information.
* **Contract Interface:** Open smart contract interfaces enable developers to directly interact with on-chain contracts, facilitating the creation of diverse DeFi applications.


# 4. Decentralized Governance

1DEX adheres to the principles of decentralization, implementing community governance to ensure fairness and sustainability:

* **Pool Management:** Smart contracts automatically manage liquidity pools, ensuring asset liquidity and security.
* **Fee Rate Adjustment:** The community can propose and vote on transaction fee adjustments, ensuring a fair fee structure.
* **Proposal Voting:** Users can participate in platform governance by proposing and voting on platform rules, feature upgrades, and other decisions, achieving true decentralized decision-making.


# 5. Privacy-Based Account Access

1DEX prioritizes user privacy, offering flexible account management and permission control mechanisms:

* **Sub-Account Activation:** Allows users to create sub-accounts for asset isolation and management across different scenarios.
* **Funding Allocation:** Users can flexibly allocate funds to different accounts or purposes, improving capital efficiency.
* **Permission Control:** Fine-grained permission settings ensure users maintain full control over account operations, reducing risks of errors or unauthorized access.


# 6. Shared Order Book

1DEX utilizes a shared order book mechanism to ensure efficient and transparent trading:

* **High-Performance Order Matching:** The order book supports millisecond-level transaction execution, processing over 10,000 transactions per second (TPS) with instant finality, effortlessly handling high concurrency.
* **Transparency Assurance:** All transaction data is recorded in real-time via on-chain matching and settlement mechanisms, immutable and publicly verifiable.
* **No Single Point of Failure:** Built on a serverless architecture and automated smart contracts, the system eliminates single points of failure, ensuring 24/7 stability.


# 7. Asset Deposit & Withdrawal for Passkey Users

Users who log in via third-party authorization can verify their identity with Passkey and create a 1DEX blockchain account, ensuring self-custody and asset security.

When Passkey users perform Deposit or Withdrawal operations, 1DEX enables cross-chain transfers between the user's source chain assets and their 1DEX blockchain account via the exSat Bridge.

\
exSat Bridge  is a secure cross-chain bridge under the custody of licensed custodians, Such as Ceffu, Cactus, and ChainUp. [About exSat Bridge >](https://docs.exsat.network/user-guides/bridge-your-btc#integrated-custodians)

The process is as follows:

When depositing assets (such as BTC or USDT), the funds are directly transferred to the user’s 1DEX blockchain account via the exSat Bridge. For withdrawals, after Passkey verification, assets are transferred from the user’s 1DEX blockchain account to the target chain specified by the user through the exSat Bridge.

Throughout the entire bridging process, 1DEX has no access to user assets, ensuring the security of funds. This design leverages the high security of Passkey and the bridging capability of exSat Bridge to provide users with a secure and efficient asset management experience.

<br>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeR_9mQgqCX2-uuV00bzrYJimar9StXTvLdcOTBNV0uZj2E1eFQLH5GPBK_O6tle0jDTR8Z9bpD2Nx0F5vVSx0nSqCVgHL-Ao_ElOUFL8hJdZc4oKl8grcNQchbDtWwSxjV9ntXGw?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>


# Summary

1DEX’s technical architecture centers on user experience, integrating innovations like PassKey authentication, a shared order book, decentralized governance, and developer support to achieve a perfect balance of security, efficiency, transparency, and openness. We ensure asset security through passwordless authentication and on-chain verification, deliver a seamless trading experience with high performance and low fees, and foster co-creation with the community through open SDKs and governance mechanisms, collectively building the future of DeFi.


# What is PassKey?

PassKey is a next-generation identity authentication technology, widely adopted and jointly promoted by Apple, Google, and Microsoft. Combining advanced cryptography with biometric features (such as fingerprint or facial recognition), PassKey offers anti-phishing protection, hardware-level security, and military-grade safeguards. Its global adoption provides users with top-tier security and convenience.

<figure><img src="/files/2ywJ1sdXSzRG7KWxPLbz" alt=""><figcaption></figcaption></figure>

## Advantages of PassKey

1. **Enhanced Security**\
   PassKey generates and stores private keys on the user’s device using encryption, mitigating the risks of traditional passwords being cracked or leaked. Paired with biometric authentication, it ensures that only the rightful owner can access the account.

2. **Anti-Phishing Protection**\
   PassKey’s authentication process is tied to specific domains, eliminating the possibility of fake websites stealing user information, significantly enhancing resistance to phishing attacks.

3. **Convenient User Experience**\
   No need to remember private keys or lengthy passwords—just a simple touch of a finger or a facial scan completes the authentication, making the process fast and intuitive.

4. **Cross-Platform Compatibility**\
   PassKey supports multiple devices and operating systems, allowing users to seamlessly use it across phones, computers, and other devices with a consistent experience.

5. **Decentralized Control**\
   Private keys are managed locally by the user, without reliance on centralized servers, aligning with the core principles of blockchain decentralization and enhancing user control over their assets.

<br>


# Why Choose PassKey?

## Redefining Blockchain Account Security: Turn Your Device into Your Hardware Wallet

One of our core philosophies is to elevate the security and user experience of blockchain accounts to the highest level. While traditional hardware wallets offer top-tier security, their physical nature and operational complexity create significant barriers to widespread adoption: users cannot always carry a dedicated hardware device, and it’s challenging to expect average users to understand complex processes like mnemonic phrase backups.

## Core Breakthrough: Empowering Everyday Devices with Secure Chip Capabilities

We propose a groundbreaking concept: Why not transform the phones and computers people already own into hardware wallets? By deeply integrating with the built-in secure chips of devices (such as the iPhone’s Secure Enclave or Android’s Titan M chip), we enable the following natively on mobile devices:

* **Hardware-Level Security:** Private key generation, storage, and signing are entirely handled within the secure chip, completely isolated from network attacks and malware.
* **Seamless User Experience:** No additional hardware is required—users can achieve hardware wallet-grade security using their everyday phone or computer.

## The Perfect Balance of Security and Convenience

✅ Biometric Authentication (Fingerprint/Facial Recognition) or Device PIN replaces plaintext private key operations, completely eliminating the risk of human error or leaks.

✅ Deep Integration with Device Secure Chips: Even if a device is lost, private keys can be securely restored via cloud backup (requires user activation).

<br>


# PassKey in 1DEX Applications

## The Perfect Blend of Security and Convenience

PassKey technology offers 1DEX an innovative private key management solution. By generating and storing private keys in a device's secure chip (such as Secure Enclave or TPM), users no longer need to worry about the storage and security of their private keys, enabling safe and convenient transactions. Below is the core process:

## The Core of PassKey: Public-Private Key Pair

* **Private Key:** Generated and permanently stored within the device’s secure chip, never leaving the secure environment, and used solely for local signing.
* **Public Key:** Used to generate the user’s unique address on the blockchain and for subsequent signature verification.

## **Transaction Process**

1. **Transaction Initiation:** The user submits a transaction request on 1DEX, generating transaction data to be signed.
2. I**dentity Verification:** The device prompts the user to verify their PassKey using fingerprint, facial recognition, or a PIN code.
3. **Local Signing:** Upon successful verification, the secure chip signs the transaction with the private key, producing a signature compliant with blockchain standards.
4. **On-Chain Verification:** The signature and transaction data are broadcast to the blockchain, where nodes verify its legitimacy using the public key before completing the transaction.

## **Security and Backup**

* **Zero-Touch Private Key:** 1DEX and other third parties only interact with signed transaction data and cannot directly access the private key.
* **Backup Mechanism:** PassKey supports private key backup via cloud sync (e.g., iCloud Keychain or Google Password Manager), mitigating the risk of device loss.


# Creating a PassKey

When users deposit funds, they are required to create a PassKey. During the deposit process, the system will create a blockchain account and bind its permissions to the PassKey. Users can then verify their identity with the PassKey to complete on-chain signature transactions for their blockchain account.

\
\
**(1) After logging in, click on Deposit to enter the PassKey creation process.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXemEXNMSTFP9ZDTG5WRFsLUrGVlAtaHJHoi8GUb0X9E55LAmot7VvfwNK5G6uLhLCK97_cWq_kZbCbLcgGNz2dvhNYIaoyMiwYyfMCGb6J7TQWmZ8QUSRsIu8hpbJ7ie1mLN2CS?key=plwL78WbXNURUi1RDcEVphc0)

**(2) Click on Create PassKey and follow the system pop-up prompts to complete the PassKey setup.**

<figure><img src="/files/UZWgLzrZV6tuhoDcXbUF" alt=""><figcaption></figcaption></figure>

**(3) Once the PassKey is created, click Deposit Now to proceed with the deposit. After completing the first deposit, the blockchain account will be created.**

<br>


# Add and Authorize PassKeys

To enhance the security of users’ accounts and funds, we recommend creating PassKeys across multiple devices and storage methods.

**(1) Navigate to the PassKey management page through the Personal Center.**

(Note: Only users who have completed their first deposit can view their account security level and access the PassKey management page.)

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXclqrZ-8X7eI4fycIOJbWxIG2ruwPi5yk1GrQiyrHvZUvwUsqmzr237wNZPgponYEu4D_h1cE8UZhTvoY9V39YDHDiEl_pEEyx9NPqw7r74bfunTiqy98o5wY5NK9vIAO02PSKsjg?key=plwL78WbXNURUi1RDcEVphc0)

\
**(2) Click on Add a PassKey to invoke the system’s PassKey component and complete the creation of a new PassKey.**

<figure><img src="/files/oaCMDJNkNbWhzOYU2J1t" alt=""><figcaption></figcaption></figure>

**(3) After creating the new PassKey, you need to use a PassKey with existing account permissions to sign and authorize the new PassKey.**

<figure><img src="/files/qns6ySYZqPi0l6EyTncH" alt=""><figcaption></figcaption></figure>


# Authorize Passkey with your Bound Vaulta Account

Binding your Vaulta account can enhance the security level of your 1dex account. If you lose your device, you can quickly create a new passkey on a new device and authorize it with your bound Vaulta account.

1. **Bind Your Vaulta Account.**

{% embed url="<https://youtu.be/wAjthNlFits>" %}

2. **When logging in on a new device through Apple or Google, select "Add a Passkey".**

<figure><img src="/files/kdI52IEOvisskQ05QyYq" alt=""><figcaption></figcaption></figure>

3. **Authorize a new passkey using your bound Vaulta Account.**

<figure><img src="/files/HwgMFciUJYwxquT86z8m" alt=""><figcaption></figcaption></figure>

4. **Launch Anchor and sign the transaction with your active Vaulta account.**

<figure><img src="/files/gLiPZUVFYG07A1YPDvAn" alt=""><figcaption></figcaption></figure>

If you see a "This request has a forbidden action" popup and cannot authorize the signature:

<figure><img src="/files/sSjT2jJzFm6ypmzg31MQ" alt=""><figcaption></figcaption></figure>

Then open the Anchor settings:

<figure><img src="/files/XJBQpxHXPb5u162MV6KB" alt=""><figcaption></figcaption></figure>

Scroll down to find Advanced Options, select "Allow dangerous transactions" as shown in the image below, then try again to authorize the signature normally.

<figure><img src="/files/sIYlLi01XJLvNxI4XsX0" alt=""><figcaption></figcaption></figure>

5. **Complete the authorization by signing the request with your Vaulta account.**

<figure><img src="/files/B6H9lzjjlpxCUl7q8Tm0" alt=""><figcaption></figcaption></figure>


# Devices and Browsers Supporting PassKey

## 💻 📱 Supported Devices:

* A laptop or desktop with at least Windows 10, macOS Ventura ( with Touch ID support ), or ChromeOS 109.
* A phone with at least iOS 16 or Android 9 ( equipped with Google Services ).
* A pad with at least iPadOS 16 or Android 9 ( equipped with Google Services ).
* A hardware security key supporting FIDO2.

## 🌍 Supported Browsers:

* Chrome 109 or up
* Safari 16 or up
* Edge 109 or up
* Firefox 122 or up


# How to add a Passkey with different storage methods?

Passkey is a secure and convenient authentication method that works across devices and platforms, offering flexible storage options.&#x20;

On **Apple system devices**, you can store a Passkey in **iCloud Keychain** by enabling iCloud and fingerprint recognition, or use Chrome with a Gmail account to save it in **Google Password Manager**. For local storage, opt for **Chrome on Mac** (device-specific only), or add it to other devices by scanning a QR code.

For **Windows system devices**, store a Passkey in **Google Password Manager** via Chrome and a Gmail account with fingerprint verification, or choose **Windows Hello** for local storage.

Each method seamlessly adapts to your device needs.


# Passkey storage on Apple devices

## **1. How to store a Passkey in iCloud on an Apple system device?**

(1) To store it in iCloud, you need to log in with your Apple ID and enable iCloud. The device must also have fingerprint recognition enabled.\
![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcy9gkSPe3DDKwg1AHORoxZcAG2OtzguVmh05TpN0eXwz48PAGUyXnn6okHzyDECpWEu4TE7uhnnFbU3v3qN7sWkYMTVUbbQAHS4GWeymBgxQKI_qeag9pBv-pnhhHt4CWhhxFm?key=plwL78WbXNURUi1RDcEVphc0)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXexA2wYGjtanJz546BfPQt84XZn6Agi3ZTjqmqvxn5wHYSrpkEMckzX-f8m_jFcj4uTyN4P8WFj0JqxpPvFbU2BoqYShhV4Fs2Cfgb9g5_Fsc0Qo3NP9o0NtPWFBIMFe7VPRl6q?key=plwL78WbXNURUi1RDcEVphc0)

(2) When adding a Passkey, if the default option to save it in iCloud doesn’t appear, you need to click \[Save another way] and then select iCloud Keychain.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd_QPB9gOd8eS3q6I8zQ29m8FM6F2F_luwpRm_wPeg2cg8ejFQOcjKaTwujOOIgSPQY-7dsFG6ShguVWbt5jgR-od5O7uTX0of1SrSWowtRLJ6kUttK5tbbPO4PURzC_HhsgoU-pw?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcXK1nTqSzFvsO2js93ZPydiqBSO0vpCIEtyIB46YqUyGv3hSsYwyy11UpIah9urM5IAlGJH3n5MrDVHH_SIU6eIkgyG29FJzYzP3B783pGCTnLwUrsjnPNORIyv5XCVO7BMCdC?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(3) After selecting it, the iCloud storage option will appear. Enter your fingerprint to complete the addition of the Passkey.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeRA63Rkxxl7RsPjkem74L7v5u2oQa7Acr6NPqjhe961pdSlyDw8ELDtxMYuGzzuoRrFk6YlYqjt-aRSAahNtXyfy0D6xh9LUBCcHj74KUaW6VqLXbKUSMJbjZB5yyMsc7vsiI3Gg?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

***

## **2. How to store a Passkey in Google Password Manager on an Apple system device?**

(1) Please use the Chrome browser, log in to your Gmail account, and visit 1dex.com.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdxQSdkX66-bGQ0KQCj7vugdZ_bM6t_ruEELQctPmSfre-GDu7ALI8gZbUWATyAV6A8T4Lzs05Yhd_0zaaavke0gbBI-c5ALryOdHKIy24IM47skcQffkcDIDAfBiS3Dny-ERHG?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(2) When adding a Passkey, if the default option to save it in Google Password Manager doesn’t appear, first click \[Cancel]. Then, when the system pop-up appears, select Google Password Manager.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcIc9mRbyU-208h5haf7r-Ry4Zs9M0wSX7XtPUwoCHyCfDJwE0tU4df_mgRYGfG38_2VYaLermx_iaoWr-gurX4ZWrg0YqWaK4YPg2_YuyvezdqiF4jBQovbmoJZvkpM7S6nbYogw?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcvrEhROFlHVTyxqmsrJJ8Wehg6Opk-Ie9HTiqVWGsotezTjQFTnzDN9gktaDGYFnk-emQfSTwuBGBLE_7xsmygJiInCFfYEwRfJMOT_AFIziOsGwAN16Adgxv3EV_JJGX6q9rH7A?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(3) After selecting it, the Google Password Manager storage option will appear. Enter your fingerprint to complete the addition of the Passkey.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc0Qb6THlchtlnJxJ5PiHBhR1S4Bw1KeU6qY_cze4dR_rA59bOf5VhbPgMuzF1nLgjAI0Drxe_n4Yhx9IYJjx6KCAQ7hd4LQ07EPMejju_peTEV9dllBHxI_MAtufuXy9v7PpYKJg?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

***

## **3. How to store a Passkey in Chrome on Mac on an Apple system device?**

(1) Please use the Chrome browser, log in to your Gmail account, and visit 1dex.com.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdxQSdkX66-bGQ0KQCj7vugdZ_bM6t_ruEELQctPmSfre-GDu7ALI8gZbUWATyAV6A8T4Lzs05Yhd_0zaaavke0gbBI-c5ALryOdHKIy24IM47skcQffkcDIDAfBiS3Dny-ERHG?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(2) When adding a Passkey, if the default option to save it in Chrome on Mac doesn’t appear, first click \[Cancel]. Then, when the system pop-up appears, select \[Your Chrome profile].

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcIc9mRbyU-208h5haf7r-Ry4Zs9M0wSX7XtPUwoCHyCfDJwE0tU4df_mgRYGfG38_2VYaLermx_iaoWr-gurX4ZWrg0YqWaK4YPg2_YuyvezdqiF4jBQovbmoJZvkpM7S6nbYogw?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfpcSBv90yIqY2jzdXGnTN4ZaPe_6U2rHcMIeMmRG5Qi5brStO_ieQ-WZHWpt3zwcyf9eqLIAwoNHnrTX6mFPMiTony3maUozh0p0updOYjYsFkhHwPXILtki-ZFuyS-99EkRBizA?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(3) After selecting it, click \[Continue], enter your fingerprint, and the addition of the Passkey will be completed.

(Note: This Passkey is stored locally on the device, not in the cloud.)

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeD40O1b6hvtIwLde5aN143BKrqd6w6wei8yBhUoRcZSmqUn6muYcuPogwyiU8lewt_AFcftkmwagjxv7VzCTaqb04i7esJlDB-l2YzIAe1DFrV7il4FDQnuwQYbvfpHmXi1n-GxA?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfzuZuYDLdEnGCNd_qY0DnX1V62lF7nriG2JVYMaqUsU9Bxclv1tQJFJR1imRtmsqqqb5VUrqWSN3_F8xejx9JEOVj9yF6tQhpWtLxJqFaPNT72uKWsI0RX7Pndu1raaLFkHAiLGg?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

***

## **4. How to store a Passkey on different devices by scanning a QR code on an Apple system device?**

(1) When adding a Passkey, if the default option shows adding the Passkey via QR code scanning, first click \[Cancel]. Then, when the system pop-up appears, select \[Use a phone, tablet, or security key].

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcIc9mRbyU-208h5haf7r-Ry4Zs9M0wSX7XtPUwoCHyCfDJwE0tU4df_mgRYGfG38_2VYaLermx_iaoWr-gurX4ZWrg0YqWaK4YPg2_YuyvezdqiF4jBQovbmoJZvkpM7S6nbYogw?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdsryI-PIHOremiWOC2zEunjGxQU6POd7i0INnaZhm2p74oHqb6lW0OZqT1bxVfAEvW5e2blgH9nZIgR3L_5YzZwg770gal0dZEnJO_A8UDRcbQjBJhCpcsIzbynbAmMNu0Unu_1g?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(2) Use your phone to scan the QR code and complete the addition on the phone using face recognition or fingerprint.

(Note: If both the Apple computer and the Apple phone are logged into the same iCloud account, it will indicate that a Passkey has already been created. To complete the addition, you need to log in and save it to a different iCloud account, or use a non-Apple mobile device.)

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe7e1cQUxWK8dGSD8uy5waZ5yTj7NwXeV0tmhQ0_X8MGQYpEMDgsbKfhWZtIN4qtwdf9wvdcW2dOpUBRE-KDm0idkMBsn0sPcbEcUk4-a-of7MesrE4FgpmPWiuEYeZ72qzThJM_Q?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<br>


# Passkey storage on Windows devices

**1. How to store a Passkey in Google Password Manager on a Windows system device?**

(1) Please use the Chrome browser, log in to your Gmail account, and visit 1dex.com.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdxQSdkX66-bGQ0KQCj7vugdZ_bM6t_ruEELQctPmSfre-GDu7ALI8gZbUWATyAV6A8T4Lzs05Yhd_0zaaavke0gbBI-c5ALryOdHKIy24IM47skcQffkcDIDAfBiS3Dny-ERHG?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(2) If the default option doesn’t show saving it in Google Password Manager, click \[Cancel]. Then, when the Passkey system pop-up appears, select \[Google Password Manager].

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcAEIJNg_LZYy-N3C4eAhl_Dwh2Cfa2c-nqC7l-aEPYrHsEoJNW6SURNQBmQCGadZZNdqFv3fulqRgMT8V-coYcPNv3oxpPzYQUqJS7yTDzys-ZvMZ7MevLIfVvg4TJA8gPNao9?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdyPhUY8D1Gnof6iNgGBN3uH0zHQ5UeMZUVHmMBILG5R7nKL6SnHpHtutRRSgUFZnwZLvOEP2IARWVcAduNuZ9jjDvMKTCdsyFGVpYLXFxyO0aJSfOoJ59dg_V-YC2fbcHbzQTY?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(3) Click \[Create], and a system fingerprint pop-up will appear. Enter your fingerprint to complete the Passkey addition.

(Note: If the system fingerprint pop-up doesn’t appear, it may be located in the taskbar below. Please click it to proceed with the fingerprint entry.)

<figure><img src="/files/KH7tYoYaJLU7MQbKJZ4X" alt=""><figcaption></figcaption></figure>

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcpl11wlx8YX-Csz6-f0GaT0cHrlM8Q4iXJ1cKe2p2iho9HapgRB7c8Gtw7RFFk2kT3PlVPlUc_YTs5QH9YUxyJNycaCzwYii_fSFJgmBEjcEb-8hbAC4a8S5JZF1HKMuPCQFBrsQ?key=plwL78WbXNURUi1RDcEVphc0)

<br>

***

## **2. How to store a Passkey in Windows Hello on a Windows system device?**

(1) If the default option doesn’t show saving it in Windows Hello, click \[Save another way] and select \[Windows Hello].

<figure><img src="/files/Fm42uL6JWJn1RXDdzNA6" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeIhWD6Jy_P1YhdlcEiz8yBat7w2LbSGw6wb6w2BQmwj8HIUGQGMQ--Eh7MP3CsBeKrevcF6k8bHVYjcrTci4IBsjdHu03603wZ2-S_0a5KQB1jZzL0HX_kCYlSuRyaHjeLIYaIlQ?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

(2) A system fingerprint pop-up will appear. Enter your fingerprint to complete the Passkey addition.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeSonit3XRYFWxtpU7fL_HnlWKCQ13UawdfmFHBRAEibiH-IQxxHiLORR62_VNQkexasp2KuooUM-cjKCsDh33TzQPGIcL3Z9PKJ9xGo3tYWzq0D4qEyM98QqNxA5uE_vNZMv0ewg?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<br>


# How to Delete a PassKey?

Before deleting a PassKey, please ensure that you no longer need to use it and understand the potential impacts of deletion. If your account only has one authorized PassKey remaining, we will not allow you to delete it from the management page list.<br>

**(1) Navigate to the PassKey management page from the Personal Center, and click on the Edit icon in the top right corner.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdN0CqYktQGnGRxr8gBRoaSvpajaWNdBchHnE0btORHq4aQg0l_B1FQKNYvyPr7n-X6-K4NgzdrnAqv0ks9GXEZD8K3Lcx-O-vTyafYFa0fpp9QaEHUyl4WtWGAqDoTGHaCoDMpiA?key=plwL78WbXNURUi1RDcEVphc0)

**(2) Click on the \[-] icon on the left to initiate the deletion process.**

<figure><img src="/files/Zz13ePk5rSmzw6LAqO89" alt=""><figcaption></figcaption></figure>

&#x20;**(3) After three confirmations, the PassKey is verified, and the deletion is successful.**

<figure><img src="/files/JWWMsvXfXBDGm1lAovqw" alt=""><figcaption></figcaption></figure>

<br>


# PassKey FAQs and Solutions

We have compiled some common issues reported by users. Please refer to the solutions provided. If your issue is not listed among the common problems below, you can submit a form to us. Thank you for your cooperation!

{% embed url="<https://forms.gle/hrfgxx6Q98iKcVDk6>" fullWidth="false" %}

***

## **1. I’m using a Windows PC, and after clicking Create, I don’t see the next pop-up window, or there’s no response. What should I do?**

<figure><img src="/files/33d8GCJJEVMA9Tww6Ewn" alt=""><figcaption></figcaption></figure>

**Solution:** If you’re using a Windows system and your PassKey is stored in Google Password Manager, the pop-up window for creating or accessing the PassKey will appear in the taskbar at the bottom of your desktop. Please check the taskbar, click to display the pop-up, and proceed with the next steps.

***

##

## **2. When creating a PassKey via QR code scanning or verifying with a QR code, the scan fails or shows a timeout. How can I resolve this?**

<figure><img src="/files/5OHUD0Vcl2D0G7vJA6rb" alt=""><figcaption></figcaption></figure>

**Solution:** Please turn off Bluetooth on both devices and then turn it back on to reactivate the Bluetooth component. Afterward, try scanning the QR code again.

***

##

## **3. Why is a PassKey stored in Google Password Manager sometimes unavailable for use?**

<figure><img src="/files/3Hxyw9bjf3SpYmMkJ2Bo" alt=""><figcaption></figcaption></figure>

**Solution:** When using Google-related services, please ensure that your VPN is enabled. Otherwise, you may not be able to access or use the PassKey.

***

##

## 4. I’m using a Windows 10 system. How can I use PassKey?

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdwVbWD6UaENgvB-V2XkmMseJgzR1GE1HO-wZNw8BqhViBlGVr0SZuoJonpIP4P4BP0hXp4bns9VSRQpkNLdpifTiMsK1ndnC5oPmiqEK8PAdgIeuXr6VHV24p_4fsSbiFBgad28A?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcUvNTbcxQeaNYzlj-FNRqHNfvsQQHi2byeE8g0f6LUD1F92X5tpCgRTobPidCk_wZeKoG0GRuQ8upoTXgCO97kKtMmVZDIgs-VwT5luDBCUWcbbE3imEbcv_wYHnNWcuhoX6YR?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

**Solution:** We recommend using the Chrome browser and logging into your Gmail account to store the PassKey in Google Password Manager.

***

\ <br>


# Account Security Levels

After completing your first deposit, you can access the Account Security Level section through the Personal Center.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXc6ACpIcrQPN8_2-KIhzYGE3aoeWtYXfAukzeR59VoNpr-iiosku-uBAaDPCEr0YS9ckrVZXYjbww56FH4dhpvGTLspKbzkjt6TixZi68aRta7yCmRTPmRDqdTwtlN_JSZ8HtfOqQ?key=plwL78WbXNURUi1RDcEVphc0)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfA7EU94DmCwySWdzgaCNNVXHMIAr7cbV60KCP4f9rEO_r-gDc8VFPzUu3dQLckpWOJ71GzuIUAtyB2XLFkNPNf_KcomZuAUOjBPWrDq8urJDExZB7Eoy7oryGESCzsMs6OTpdCwQ?key=plwL78WbXNURUi1RDcEVphc0)

**Security Level Assessment:**

* <mark style="color:red;">**Low: 1**</mark> PassKey authorized
* <mark style="color:orange;">**Medium: 2**</mark> PassKeys authorized
* <mark style="color:green;">**High: 3**</mark> PassKeys authorized

**To ensure the security of your account, we recommend authorizing at least 2 PassKeys.**

<br>


# Onboarding

**What do I need to trade on 1DEX?**

You can trade on 1DEX with a wallet or by logging in with your Apple, Google account.

**If you choose to use the Apple or Google account, you need:**

1. **A Passkey-enabled device**

Currently Passkey supports computer operating systems: Windows 10, macOS Ventura (Touch ID required) or ChromeOS 109 and above. Supported mobile tablet operating systems: iOS 16 or Android 9 (Google Services required) and above. Supported browser versions: Chrome 109 and above, Safari 16 and above, Edge 109 and above, Firefox 122 and above.

2. **Zero gas fee**

Apple and Google account transactions zero gas fee.

**If you choose to use a EVM wallet, you need:**

1. **An EVM wallet**

* If you don’t already have an EVM wallet (e.g., MetaMask, OKX Wellet, WalletConnect, Coinbase Wallet), you can easily download an EVM wallet from <https://walletguide.walletconnect.network>.
* After downloading the EVM wallet or extension, create or import a EVM wallet.

2. **Add exSat Mainnet**

Currently, 1DEX only supports exSat Mainnet connections. You need to add exSat Mainnet to the wallet you are using. A tutorial for adding exSat Mainnet to your wallet can be found at: <https://docs.exsat.network/user-guides/wallet-setup>.

3. **exSat Mainnet gas fee**

exSat Mainnet uses BTC as gas fee, and you need to prepare some BTC as gas in your wallet. Alternatively, you can also use exSat bridge (<https://exsat.network/app/bridge>) to cross-chain USDT or USDC to the exSat Mainnet chain. Please prepare at least 2USDT or 2USDC, and turn on the "Buy BTC from deposit for Gas" option. exSat bridge will automatically swap 2USDT for exSat Mainnet BTC as a gas fee.

**If you choose to use a Vaulta wallet, you need:**

1. **An Vaulta wallet**

* If you don't already have a Vaulta wallet (e.g. Anchor or TokenPocket), you can easily download an Anchor wallet from <https://www.greymass.com/anchor#download> or a TokenPocket wallet from <https://www.tokenpocket.pro/en/download/app> to download the TokenPocket wallet.
* After downloading the Vaulta wallet or extension, create or import a Vaulta wallet.


# Logging In

**How to log in to 1DEX?**

**If you choose to sign in with your Apple, Google account:**

1. Click "Continue with Apple" or "Continue with Google" to log in with your Apple or Google account and authorize it to create a 1DEX account.
2. You're now connected. Next, create a Passkey, as it will be used for secure verification in all transactions and withdrawals. Click the "Deposit" button then click the "Create Passkey" button to create a passkey for 1DEX.

{% embed url="<https://youtu.be/R3-s5HnnHJU>" %}

**If you choose to sign in with a EVM wallet:**

1. Click the “EVM Wallet” button and choose a wallet to connect. A pop-up will appear in your wallet extension asking you to connect to 1DEX, click the "Connect" button to log in to 1DEX.

{% embed url="<https://youtu.be/cB7Wr9YGcug>" %}

2. Now you have connected your wallet. The next step is to cross the assets to the exSat Mainnet chain. You can use exSat bridge (<https://exsat.network/app/bridge>) to cross the assets to exSat Mainnet.

{% embed url="<https://youtu.be/4ZrcssKpQe8>" %}

**If you choose to sign in with a Vaulta wallet:**

1. Click the "Vaulta Wallet" button, and then the browser will request to open the local Anchor Wallet. Your Anchor Wallet will automatically open the "Signing Request" window, click on your Vaulta account, enter the password, and click "Authorize" button to log in to 1DEX.

{% embed url="<https://youtu.be/e3-eACbWya8>" %}

2. Alternatively, you can open the TokenPocket App on your phone, switch to the "Discover" menu, click the top search box, enter "[1dex.com](http://1dex.com/)" to access 1DEX. Click the "Vaulta Wallet" button, then click "TokenPocket" to log in to 1DEX.

{% embed url="<https://youtu.be/cUFBXYIKSpM>" %}


# Depositing Funds

**(1) The first deposit requires completing the creation of a PassKey. Navigate to the deposit process through the Deposit entry on the Personal Center/Assets page.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeEBkSxD2YeHtHTU-od8-TWHwl_O-qOTKy5YuEfFa-DG9JHlJeol_5qVPArjoRr7lG1ViWo3mb6fR6T4BTC842treSC2gAKUt6DTVeBNrqZOS7FM9_Scj5JJ186p7TUTA8q7H7LHA?key=plwL78WbXNURUi1RDcEVphc0)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXe-EFENNodYAXN3uXsr0ZGz1lAS8tJhXMU4p0nIKvxUBI2t2ksd_HMKFgZxqPmOQs7f6CcdaOLIPD8NLPAAAXzoGwDlARMXdstxamra5gDJE5ZItWkdVn0qLwN_sa2slMsMufvv?key=plwL78WbXNURUi1RDcEVphc0)

<br>

**(2) After selecting the token and network, obtain your deposit address. Click Copy Address, then use a blockchain wallet to transfer the tokens from the selected network to this deposit address. Refresh the Deposit Records and account balance to check the status of the deposit.**

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf0bOvyqHU_AzdsoigTUEfSZ0lM6aMPGRiSIiTp5WJeMObFjVxYT_x7yG1I5hKK30JRkm6ZW6DcT8ERiYNBX4PVGWpMVZ01qNR_tnlRc3C7KcAI9ungwY1J07wtuLpaNXi6WL6m?key=plwL78WbXNURUi1RDcEVphc0" alt=""><figcaption></figcaption></figure>

<br>

**(3) Regarding Deposits on the exSat EVM Network: You can complete the deposit by directly linking and transferring from an exSat wallet.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXe3J5sk_d5LqZM-rzAob5xVS3wobqeQPqcqImelWvmgLlft3TjkysOFhajpDev2zbyrxNCgMSOXKMz_xhmE9N0OqnsLi2niGwOG7iSDnmkzREJhPFlwvCvTJuioZvBlRek2_8glGw?key=plwL78WbXNURUi1RDcEVphc0)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXf2yOSRAVbJFfmEM35qVJ41hLx-8acxELrKB-jK23UGe4Gz62SSEAk_nvTpcwEZcChhMNvtb-_6fsYbTLOb8PopNJiHK8dn1jf3mQHLSyAQk4sD5RW7Tflb3hQesq6Ny3XUsZyh?key=plwL78WbXNURUi1RDcEVphc0)

<br>

**(4) Regarding Deposits on the EOS Native Network: Please ensure you enter the MEMO.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeHK_EY6pEW0J8qT_FIEAhAKxgTnZMYgBxqsHvmOi_3Yixir9kIklfLnWW_oxvM1oqjVuNHRbYk5v1zzIZfpY1vNwsjg9a77VAjjYrCdgqwxCMJWOkQekR9PFKDd8Yh0dxU5Xu1?key=plwL78WbXNURUi1RDcEVphc0)

<br>


# Withdrawing Funds

**(1) Navigate to the withdrawal process through the Withdraw entry on the Personal Center/Assets page.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfwPZuJLOHslJ3p38iw2jdSfC1sx1H71HltQokzVK0rJsUDv8sCAW5sjxojLUzks9eQjQn3YW_gZjVbYdg2-rKUQx6jaKMP5AvW3eKhCo7YnoO1ldrp95CtNWxVZXBl_5Hh4CNO4w?key=plwL78WbXNURUi1RDcEVphc0)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfnSe23BRswp5CuWa2pohOFYSL3YX3hcJniVb-MVQbeNe_Dg0i0l0llQOPLCiTxSJfrFjovUS4dYR8nY3VpkC3q96XB7dbdhmfyfvQLnFYCsIocWViUqXWwZz4WKbfReXg5ZNod?key=plwL78WbXNURUi1RDcEVphc0)<br>

**(2) Select the token and network for withdrawal, enter the destination address and the amount you wish to withdraw, then click Withdraw.**

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdahnRP6FJMYxvOJxln6mWZN6VsSZap13Eh_LfYFxi1DWJZtQDzte1cmDISdCP1Lf0AVkHK86XJaWYrvRqmQRnICb8fcPTZhsnsiNhfE8qEsGKnwWpJSAUnxtP3wEMjuAg2vnjYqA?key=plwL78WbXNURUi1RDcEVphc0)<br>

**(3) Confirm your withdrawal order details and click Continue. PassKey verification is required. Once verification is successful, the withdrawal process will be initiated. Refresh the Withdraw Records and check the balance of the withdrawal address to confirm the transaction status.**<br>

<figure><img src="/files/12LHyB61mQ3cQWuH5goT" alt=""><figcaption></figcaption></figure>


# Limit Order Trading

**Buy or sell at a specified or better price.**

## 1. Passkey Users Logging in via Third-Party Authorization:

**(1) Placing a Limit Buy Order:**&#x20;

After confirming the price and quantity, click Buy to initiate PassKey verification. Once verified, the trade will be executed.

<figure><img src="/files/cfalQHRz3RBJ1bVfZC5d" alt=""><figcaption></figcaption></figure>

**(2) Placing a Limit Sell Order:**&#x20;

After confirming the price and quantity, click Sell to initiate PassKey verification. Once verified, the trade will be executed.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfzZMrM7w-zUv8K3-A9gInt6zCk7iM5Qhk2QLRZmoK0Ht3rkdyCJ7GHruQvFz0uniPrYFSeOZgwUddu6ka6joUp35T2GWqgahdl-wH0NPnKIkF9r5zi8O8Hx3jRj8kpIwzSjbkBIQ?key=9ftifb6JAyAChTAfwKggK5Tu" alt=""><figcaption></figcaption></figure>

## 2. Users Logging in with exSat EVM Wallet:<br>

**(1) Placing a Limit Buy Order:**&#x20;

After confirming the price and quantity, click \[Buy]. Once the wallet signature is completed, an on-chain transaction will be initiated.

**Note:** For first-time transactions involving non-gas tokens, an Approve operation is required.

<figure><img src="/files/f4OlMIPrXK9wGL9OJRPL" alt=""><figcaption></figcaption></figure>

**(2) Placing a Limit Sell Order:**&#x20;

After confirming the price and quantity, click \[Sell]. Once the wallet signature is completed, an on-chain transaction will be initiated.

**Note:** For first-time transactions involving non-gas tokens, an Approve operation is required.

<figure><img src="/files/UDV6zkmRtxRS9kjchZz1" alt=""><figcaption></figcaption></figure>

\ <br>


# Market Order Trading

**Quickly buy or sell at the best available price.**

## 1. Passkey Users Logging in via Third-Party Authorization:

**(1) Placing a Market Buy Order:**&#x20;

After confirming the quantity, click Buy to initiate PassKey verification. Once verified, the trade will be executed.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdcCLbhvd957C6euQD3tTnfHO1x8Xl7e92xgkqZ_YvHV2hwn4firUE1XdWLWIBo2VlUCGDxTvdL0H0FHLatLWJO-dunLib4p83TvKXxhw9nhdOx2toyMHV20FT35_nYyJ72Oc0SOQ?key=9ftifb6JAyAChTAfwKggK5Tu" alt=""><figcaption></figcaption></figure>

**(2) Placing a Market Sell Order:**&#x20;

After confirming the quantity, click Sell to initiate PassKey verification. Once verified, the trade will be executed.

<figure><img src="/files/rk2jkGoog7eABdabLxjn" alt=""><figcaption></figcaption></figure>

## 2. Users Logging in with exSat EVM Wallet:

**(1) Placing a Market Buy Order:**&#x20;

After confirming the quantity, click \[Buy]. Once the wallet signature is completed, an on-chain transaction will be initiated.

**Note:** For first-time transactions involving non-gas tokens, an Approve operation is required.

<figure><img src="/files/vsunuyDcI4N8esktUimT" alt=""><figcaption></figcaption></figure>

**(2) Placing a Market Sell Order:**&#x20;

After confirming the quantity, click \[Sell]. Once the wallet signature is completed, an on-chain transaction will be initiated.

**Note:** For first-time transactions involving non-gas tokens, an Approve operation is required.

<figure><img src="/files/4qRDgTJZtx0MwfyxnsTu" alt=""><figcaption></figcaption></figure>

<br>


# Fees

The spot trading fees differ between two types of users.

**General users:**

* Taker 0.1%
* Maker 0.05%

**Market makers:**

* Taker 0.05%
* Maker 0%


# Deposit and Withdrawal Fee

**Deposit Fee**

Free

**Withdrawal Fee**

We will adjust the withdrawal fees according to the cryptocurrency market’s performance.

| Cryptocurrency | Withdrawal Fee | Minimum Withdrawal |
| -------------- | -------------- | ------------------ |
| BTC            | 0              | 0                  |
| A              | 0              | 0                  |
| V              | 0              | 0                  |
| XSAT           | 0              | 0                  |
| YUZU           | 0              | 0                  |
| RAMS           | 0              | 0                  |
| WRAM           | 0              | 0                  |
| UOS            | 0              | 0                  |
| USDT           | 0              | 0                  |
| USDC           | 0              | 0                  |
| METHANE        | 0              | 0                  |


# Invitation Program

The 1DEX Invitation Program allows existing 1DEX users a chance to earn rewards when inviting their friends to join and trade on 1DEX.&#x20;

1DEX Invitation Program is a way for existing users to receive commission from the trading fees of their referred users. For every new user successfully referred to 1DEX after referred user bound the relationship via My Account, the referrer will receive a cut of the trading fees paid by the referred user on 1DEX Spot.

How to earn commission from Invitation Program？

**Step 1**: Visit <https://1dex.com/invite>

**Step 2**: Create new invitation and set the commission rate of you and your friends.

**Step 3**: Share your referral link or code with friends to invite them to log in to 1DEX.

**Step 4**: Receive the commission from the trading fee paid by your referred friend.

The commission is calculated with following factors:&#x20;

**Base commission rate**: 20%, you can freely set your commission rate and your friend’s commission rate, as long as they sum to 20%.

**Your commission rate**: The share of your referred friend’s trading fee you earn.

**Your friend’s commission rate**: The share of your referred friend’s trading fee they can receive as a fee rebate.


# Incentive Points Program

Earn 1DEX Points by trading. Unlock opportunities with every trade.

On 1DEX, every trade you and your friend make is an opportunity to earn. With a cutting-edge, orderbook-based DEX, you enjoy the speed and precision of top centralized exchanges while staying true to the principles of decentralized finance.

## How It Works - Earn 1DEX Points by Trading

The 1DEX Points Program is an ongoing initiative that rewards traders for engaging with 1DEX’s high-performance trading platform. By executing trades across supported coin pairs, users earn Points with every transaction.

1DEX traders can earn Points while using the platform’s advanced orderbook to execute trades seamlessly. Points are available to all users, including makers and takers.

### Earn Trading Points

### 1. Execute Trades&#xD;

Trading on 1DEX is effortless and rewarding. For each executed spot trade that is successfully filled, you earn Points.

For every trade you make, 1DEX allocates points based on the scoring function as follows:

**Points for Taker = Base Point × Taker Weight × Pair Weight × Trading Volume (USDT)**

**Points for Maker = Base Point × Maker Weight × Pair Weight × Trading Volume (USDT)**

Base point = 1 Point

Trading Volume (USDT): Higher volumes earn more points.&#x20;

Pair Weight: Different pairs have varying Pair Weights.

Taker or Maker Weight: Weights vary between takers and makers.

### 2. Earn Points from Your Friend’s Trading

When your friend earns Points from their trades, you receive an extra 5% of their Points, calculated as:

Invitation Points = 5% × your friend's trading Points

### 3. Join Community Activities

Joining our community activities is a great way to earn points. Specific details will be announced soon on our website.

## Getting Started

Visit <https://1dex.com/points>


# Guide to Swap EOS for A

This guide will walk you through the steps to swap EOS for A on 1DEX, from depositing EOS into your 1DEX account to swapping EOS for A on 1DEX.

**If you log in with Apple or Google：**

1. Open the deposit page, select EOS for "Select Coin" and EOS for "Select Network," then click the button to copy the address and Memo.

<figure><img src="/files/2wTqEsh63lWlAzhkCL92" alt=""><figcaption></figcaption></figure>

2. When withdrawing EOS from Binance, select EOS as the "Select Coin," enter the address as **dpfund.1dex**, and **input the Memo provided by 1DEX** in the "Contract address ending in" field. Other exchanges follow similar steps.

<figure><img src="/files/xMVbDLUno2GUHs757eHY" alt=""><figcaption></figcaption></figure>

3. In the "Withdraw amount" field, enter the amount of EOS to withdraw. Click "Withdraw" or "Next" to withdraw EOS to 1DEX.

（Please confirm the address is "dpfund.1dex" and the Memo is provided by 1DEX. If the Memo is missing or incorrect, the assets may be lost.）

**If you connect with TokenPocket or Anchor：**

1. When withdrawing EOS from Binance, select EOS as the "Select Coin," enter the “Address” as your EOS address. Other exchanges follow similar steps.

<figure><img src="/files/P9imWf5AWHRjueG5ubtp" alt=""><figcaption></figcaption></figure>

2. In the "Withdraw amount" field, enter the amount of EOS to withdraw. Click "Withdraw" or "Next" to withdraw EOS to your EOS address.

**Swap EOS for A:**

1. Visit <https://1dex.com/swap-a> page, click “Swap” to swap EOS for A.

<figure><img src="/files/gJl3mA8ct0A4Nc55ER01" alt=""><figcaption></figcaption></figure>

2. Authorized signature to complete redemption.<br>


# About Stake A

### Overview

The yield for Stake A comprises two components: REX APY and BP APR. The total rewards are calculated as:

```
Total Stake A Rewards = Total REX Rewards + Total BP Rewards
```

### REX Rewards

* **Description**: \
  REX rewards are incentives provided by the Vaulta network upon purchasing REX. These rewards accrue in real-time and are settled when REX is sold.
* **Redeemable**: \
  REX is unlocked immediately upon purchase and can redeemable after a 21-day staking period. REX rewards continue until redeemed.Funds are available instantly upon redemption.
* **APY Calculation**:

  ```
  REX APY = (Today's REX Price - Yesterday's REX Price) / Yesterday's REX Price × 365 × 100%
  ```
* **Rewards Calculation**:

  ```
  Total REX Rewards = Staked & REX Rewards - Your Staked A
  ```

  \
  **Example**: If your Staked & REX Rewards is 24,485.2451 A and your Staked A is 24,434.4153 A, then:

  ```
  Total REX Rewards = 24,485.2451 A - 24,434.4153 A = 50.8298 A
  ```

### BP Rewards

* **Description**: \
  BP rewards are distributed daily and depend on the total voting amount. Higher node rankings significantly increase rewards. A 10% management fee is applied to daily BP rewards.
* **APR Calculation**:

  ```
  Yesterday's BP APR = Yesterday's Node Income / Yesterday's Average Voting Amount × 365 × 100%
  ```
* **Rewards Calculation**:

  ```
  Total BP Rewards = Sum of Daily BP Rewards
  ```

### FAQ

* **Why didn't my yield yesterday match the APR shown?** \
  If you added a new stake or made your first stake yesterday, it was active for less than 24 hours, resulting in a partial day's reward.
* **Why didn't I receive yesterday's BP reward?** \
  BP rewards are automatically settled and distributed daily by Newdex. For stability, rewards less than 0.0005 A are not transferred.

<br>


# Contact US

We value your inquiries and feedback. Here are the ways you can reach out to us:

***

## Google Form <a href="#google-form" id="google-form"></a>

Please fill out our [Google Form](https://forms.gle/hrfgxx6Q98iKcVDk6) for any general inquiries or feedback.

***

## Email <a href="#email" id="email"></a>

**Support:** <support@1dex.com>

***

## X <a href="#x" id="x"></a>

Connect with us on **X**: <https://x.com/1DEX_COM>

***

**We look forward to hearing from you!**


# Contract Audit

{% file src="/files/tVPZKlF0T9yHwXm8dGgq" %}

{% file src="/files/0JSqOzWRgQFqjcrdxmy5" %}

{% file src="/files/LLGqjRh4SWpb2k5Y7akD" %}

{% file src="/files/G8iaG9paW7q6kikiiCjB" %}


# Introduction

Official documentation for the 1Dex APIs、Websocket Streams and SDKs

**Sub-account can only be enabled and created when logging in via third-party authorization (Apple/Google). It cannot be enabled when using 'Connect Wallet' login.**

### Setting up

The first step to use `1Dex developer kits` is setting up your environments.

<table data-view="cards"><thead><tr><th></th><th data-type="content-ref"></th><th></th></tr></thead><tbody><tr><td></td><td><a href="/pages/ctWiItHE5aBIu0fjvsEX">/pages/ctWiItHE5aBIu0fjvsEX</a></td><td>Apply for an API key for the primary account, to be used with both REST API and WebSocket stream.</td></tr><tr><td></td><td><a href="/pages/opmqOnI3wqXgxou0vGMy">/pages/opmqOnI3wqXgxou0vGMy</a></td><td>Enable subaccount function to isolate trading strategies through multiple subaccounts.</td></tr></tbody></table>

### Dev kits components

The development kits consist of the following components. Click the links below to access detailed documentation for each reference:

* [Restful API Reference](/developer/restful-api-reference/overview)
* [Websocket Streams](/developer/websocket-streams/overview)
* [Javascript SDK](/developer/sdks/javascript-sdk)


# Manage Subaccounts

Enable subaccount function to isolate trading strategies through multiple subaccounts

How to Enable the Sub-Account Feature

1\. Enter the Sub-Account Management page from the Personal Center. On the Sub-Account Management page, click \[Activate Now] to start the activation process.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc4dDj8TmtgGA1uMdTgZ284APBwNs_F8a5HzKqIdCu9_z0Gzm6oidy01fR-ZOfLeANJSrpsyFlnCbz54xssrmPElyaEa2o1dDEWmkXfOlZtkyMOA4Yctg9mMxEJ_nN1l88rkJScUQ?key=TerWG0tb0-4NBBi7goDou6kh" alt=""><figcaption></figcaption></figure>

2\. Click \[Confirm], verify your Passkey, and pay 100 USDT to activate sub-account permissions.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcDfiXMmpnVYY8-hQpz--yFW9KILjoctI7SVgPxc6yPLxbAJ1Xekk021MhlSyk4KcHyJDd856Urqj3uU9DCJe7fdiElm2WjOlgWLjlQU1mkYJvBB89WkeW920tFuSjZiEdgO-FHyw?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfFJEYYj6CYd6qyq8bZu48omZthYXZFdUGrVM_cuYscJi5xtVtrsDsBcmdae38nrnVnMBsy8FdaDP3Qz6Nr4xvFLcuk-eRUzyUsd2mHkEdazq9EC5J_96f-oz2C9yFPp7NjEJvu?key=TerWG0tb0-4NBBi7goDou6kh)

***

## How to Create a Sub-Account

1\. On the Sub-Account Management page, click \[Create Sub-account] to start the creation process.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXek4OrQrCP5pfAVcxDPARg8XYBOu6O4J_RedPWMoIaJzgg8Z5hfGK69uLf5Um8ysAebfhlC0qCbA63Yx-LGI1CuUFYH0wUAZyxiNbKZI4cmwOZREdIJ9F9GgsdhMw2KHdiXnxwhOw?key=TerWG0tb0-4NBBi7goDou6kh" alt=""><figcaption></figcaption></figure>

2\. Enter the sub-account name, click \[Create], verify your Passkey, and complete the sub-account creation.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeoWKsyntaeCh69DReffkXcV7YYlBO1hxgq_NbYQus8WpOZ1TrS-rIiQa-IH621HzozoOIeSxmXA6NbI124jT-65a45mf-BgSfFNLCvU2HJN3PZsi0oksT2_SprsLzMsJSTq5J-AQ?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfFJEYYj6CYd6qyq8bZu48omZthYXZFdUGrVM_cuYscJi5xtVtrsDsBcmdae38nrnVnMBsy8FdaDP3Qz6Nr4xvFLcuk-eRUzyUsd2mHkEdazq9EC5J_96f-oz2C9yFPp7NjEJvu?key=TerWG0tb0-4NBBi7goDou6kh)

3\. Please copy the **TRADE SECRET KEY**, click \[Recorded], and confirm again.\
*Note: The **TRADE SECRET KEY** is required for the sub-account’s trading requests and is extremely important. 1DEX will not store this key for you — please make sure to copy it down and keep it safe.*

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeurjoXpIrvkMBkfxhrASWnafKCFO6pervX6a-qWlC4PwYP08TiBgqTJXc6iZtVq0zwMX6tX-MJKd0GOyht1dG_zm_dqOfnj6sVnWVKQ1E5DOtDQLnOUFXolgnuSf6rCzy_yAPNiw?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcuq-b0KLWF6SsLgKdyTZBj2JFtslIT6SkJeXapdC6D55vkUS3pHZ-xZ_K4opFw_LLsA-cyKXrPufnMjIrZ0N1x7F-Ir2pdklHFKsI7wxTlc9AzzcsvBJIO43BzCGlAVwxYgvc21Q?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdOc9vMGHYGQNLtRTJVCFAK04alpAoNqZrfJDtfgy6XSQzmz4Fc00zqgunPYNwPqQMlDYD3U5Y1nZ2bbjucMbQs33fMeKiq4wVZ1qYB1mdQ4UgIlkEp2PDaBZS4e0SXy3LNJZ6W?key=TerWG0tb0-4NBBi7goDou6kh)

<br>

***

## How to Transfer Assets

1\. On the Sub-Account Management page, click \[Transfer] to enter the asset transfer page.

*If the sub-account has assets, you will be directed to the Sub-Account Asset Management page first. From there, click \[Transfer] to start the transfer process.*

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcExNRnqxgV0zB2b9Ibadha_fJRDPte5KsVi_KedP_7oRiEKhMZoR7g5PkT7uWos-SoKUW3wsJytAZW_dDdWqOByBdA8kaEUjmJIrAh6z88NkKd-k-eZUiG0Ce9tBlxJA_6xiWFxA?key=TerWG0tb0-4NBBi7goDou6kh" alt=""><figcaption></figcaption></figure>

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfyhTrHmMKNad6Jc__ct2uavDO-ifosnoYoc907hieSUaoqs3I2kAKL4G9WQG9HYp0wv8NrWRX4JiYuopGub_mZBZmIV_SpwkvVZLRjQVyumLLpr8Ho2Ml7i1O-S_IHcnYQEOaSuQ?key=TerWG0tb0-4NBBi7goDou6kh)

2\. Select the target sub-account, the token to transfer, and the amount. Click \[Confirm], verify your Passkey, and complete the transfer from your Main Account to the Sub-Account.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdtg3zvLRvcJFOCofSTD5_hHERn78R3dTyY1SfIa2TjzvT_6eNbSjsBbOgApt9rl4Dj7r5TUD8ufqd4h3F1UjBLKuEPSQt3A4LmFlyO7ThWaRsefedsqNR9PlkSo2eQ1LXcjz3DLw?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfFJEYYj6CYd6qyq8bZu48omZthYXZFdUGrVM_cuYscJi5xtVtrsDsBcmdae38nrnVnMBsy8FdaDP3Qz6Nr4xvFLcuk-eRUzyUsd2mHkEdazq9EC5J_96f-oz2C9yFPp7NjEJvu?key=TerWG0tb0-4NBBi7goDou6kh)

<br>

***

## How to Reset TRADE SECRET KEY

If you accidentally lose your **TRADE SECRET KEY**, you can reset it by clicking \[Reset Secret Key] on the Sub-Account Management page and verifying your Passkey. A new TRADE SECRET KEY will be generated for the sub-account.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdR74lTZ9TvAXLzoz5WvRQfwWDet27f9GLGoQo_xv6ATeTx2eh9dwNKGMCgbP9gzEjDn0zguXYINhJJV1CibplB8o-qtECUSKmR13ZykrOX6ejn5Vh5msN9D8imLhYBeKp4FbJN?key=TerWG0tb0-4NBBi7goDou6kh" alt=""><figcaption></figcaption></figure>

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfFJEYYj6CYd6qyq8bZu48omZthYXZFdUGrVM_cuYscJi5xtVtrsDsBcmdae38nrnVnMBsy8FdaDP3Qz6Nr4xvFLcuk-eRUzyUsd2mHkEdazq9EC5J_96f-oz2C9yFPp7NjEJvu?key=TerWG0tb0-4NBBi7goDou6kh)

***

## Batch Transfer to Main Account

1\.  On the Sub-account Management page, click \[Batch Transfer] to start the batch transfer process.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdmtKNH7Cu7yrbwULz4ElnNGxx2Ia2UayirAMkX_uf1qGFT4zMwm-3hgTHiWuuAmWtdnQ1qg0bvd4BoyKN27fSA2cO93qrk_9__J6bBr_I2P2Qh0UJZ5L1fYWc7i-305a0RR_M32Q?key=TerWG0tb0-4NBBi7goDou6kh" alt=""><figcaption></figcaption></figure>

2\. View the assets of the sub-account, click \[Batch Transfer], verify with Passkey, and complete the batch transfer operation.\
*Note: The batch transfer function only supports transferring assets from sub-accounts back to the main account.*

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfG3e-Oq19MbL4RAcQd_YMPY6DThhBq3TRPQ4UTMN7JuDn4SAFI3Jgt5pef14bwjSBs8sd1kDMsQItCYpNQdJN9xJ4-CrXLOW-_Ttu3s3Pcjiybp7KXrgFta2QxhWxqo9jvA7JxKQ?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeZrBU4VMzt4YrKXrfBGxL7q1eLJnGrluKYdFhQ1YizAMCDd2WfFIvBJgvgyeyDrZE7D-1Gx0_521uDDfnzRf-N4QMG5B41szrCy1gPcOQvFbmf5zc1u3mhHaQblv2DZq2wvAlC?key=TerWG0tb0-4NBBi7goDou6kh)![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdqmc8sM5zpgh5_HeRfxrZlI1w5ujDcG7fq3DHQVBKpBEKovQsYdxW3bqSQvFqRJWEuP8V5Zc3LyEtYMQDbEIVYILD1JKLN94rOCf0SdhYOkG_JCU-tJjUMUQUDxIyEFaM8AbNafg?key=TerWG0tb0-4NBBi7goDou6kh)

<br>

***

<br>


# Apply API Key

Apply for an API key for the primary account, to be used with both REST API and WebSocket stream

After creating the sub-account, go to the Sub-Account Management page and find the API Key in the list. Click to copy it to your program, and you will be able to access the relevant trading information and more for that sub-account.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd4jkyHPXBfOOJVZKJFQVgAa7rPYi7LO4Y2uGBFsvRGZML7VF8sUUtJPPEr_of_wPBsdD7RxxCgntIhSWiJaiTosS5B5Hz3IhMa6f63ep0upU-efv9Rh25Nf9uXEIeXiOBWMg5wdg?key=TerWG0tb0-4NBBi7goDou6kh" alt=""><figcaption></figcaption></figure>


# Javascript SDK

A powerful JavaScript SDK for integrating with the 1DEX decentralized exchange platform, providing seamless access to trading functionality and market data.

### 1DEX JavaScript SDK

A powerful JavaScript SDK for integrating with the 1DEX decentralized exchange platform, providing seamless access to trading functionality and market data.

### Installation

```bash
npm install 1dex-js-sdk
```

### Getting Started

#### Initializing the SDK

```typescript
import { DexKit, ETradeSide, EOrderType } from "1dex-js-sdk";

// Create a new DexKit instance
const dexKit = new DexKit({
  apiKey: "YOUR_API_KEY",
  secretKey: "YOUR_SECRET_KEY",
  enableProxy: false, // Optional, defaults to true
  apiClientConfig: {
    baseUrl: "https://api-v1.example.com", // Optional, defaults to 'https://api-v1.1dex.com'
  },
  blockchainRpcClientConfig: {
    chainID: "YOUR_CHAIN_ID", // Optional, defaults to 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
    rpcUrl: "https://rpc.example.com", // Optional, defaults to 'https://spring-rpc.1dex.com'
  },
  devMode: false, // Optional, if set to true, it will output debug information of certain methods in the console
  version: "v2" // Optional, if set to 'v2', it will enable AMM listing, default is 'v1'
});

// Initialize the DexKit instance
await dexKit.initialize();
```

### DexKit Interface

The DexKit class provides methods for trading operations on 1DEX.

#### Core Methods

**`initialize()`**

Initializes the DexKit instance by fetching system metadata, account information, and pool data.

```typescript
await dexKit.initialize();
```

**`initializeWithProvidedConfig(config)`**

Initializes the DexKit instance using the provided configuration instead of getting it from the server.

**All parameters are optional.**

```typescript
dexKit.initializeWithProvidedConfig({
  appContract: "app_contract", // app.1dex
  accountContract: "account_contract", // Your main account name
  pools: [
    {
      id: 1,
      baseToken: "TOKEN1",
      quoteToken: "TOKEN2",
      baseTokenContract: "token1.contract",
      quoteTokenContract: "token2.contract",
      baseTokenDecimals: 4,
      quoteTokenDecimals: 4,
      pricePrecision: 4,
    },
  ],
  proxyAccount: {
    name: "proxy.account",
    permission: "active",
  },
  account: {
    name: "user.account", // Your sub-account name
    permission: "trader", // Your sub-account permission
  },
});
```

**`placeLimitOrder(params)`**

Places a limit order on the specified pool.

If it is a **buy order**, the amount is the quantity of **quote coin**, if it is a **sell order**, the amount is the quantity of **base coin**.

For example, there is a BTC/USDT trading pair. If it is a buy order, 'amount = 80000' means '80000 USDT', if it is a sell order, 'amount = 1' means '1 BTC'.

Note: the amount will be **rounded up** to the precision unit, which means that if you enter **10.00001 EOS**, it will be formatted as **10.0001 EOS**, so it is recommended to enter the amount according to the token decimals.

```typescript
const { txID, clientOrderID } = await dexKit.placeLimitOrder({
  poolID: 1,
  side: ETradeSide.BUY, // or ETradeSide.SELL
  orderType: EOrderType.NO_RESTRICTION, // or EOrderType.IMMEDIATE_OR_CANCEL || EOrderType.FILL_OR_KILL || EOrderType.POST_ONLY
  amount: "10.0000", // if 'buy', amount is quote coin quantity; if 'sell', amount is base coin quantity
  price: "0.5000",
  clientOrderID: "your defined client order id", // optional
});
```

**`placeMarketOrder(params)`**

Places a market order on the specified pool.

If it is a **buy order**, the amount is the quantity of **quote coin**, if it is a **sell order**, the amount is the quantity of **base coin**.

For example, there is a BTC/USDT trading pair. If it is a buy order, 'amount = 80000' means '80000 USDT', if it is a sell order, 'amount = 1' means '1 BTC'.

Note: the amount will be **rounded up** to the precision unit, which means that if you enter **10.00001 EOS**, it will be formatted as **10.0001 EOS**, so it is recommended to enter the amount according to the token decimals.

```typescript
const { txID, clientOrderID } = await dexKit.placeMarketOrder({
  poolID: 1,
  side: ETradeSide.BUY, // or ETradeSide.SELL
  amount: "10.0000", // if 'buy', amount is quote coin quantity; if 'sell', amount is base coin quantity
  clientOrderID: "your defined client order id", // optional
});
```

**`cancelOrder(params)`**

Cancels an existing order.

```typescript
const txID = await dexKit.cancelOrder({
  poolID: 1,
  orderID: 1,
  side: ETradeSide.BUY, // or ETradeSide.SELL
});
```

**`cancelOrderByCid(cid)`**

Cancels an existing order by client order id.

Client order id will be returned by `placeMarketOrder` and `placeLimitOrder`.

```typescript
const txID = await dexKit.cancelOrderByCid(cid);
```

**`batchCancelOrders(params)`**

Cancels multiple open orders at once.

```typescript
const txID = await dexKit.batchCancelOrders({
  poolID: 1, // optional
  side: ETradeSide.SELL, // optional, ETradeSide.SELL or ETradeSide.BUY
  limit: 100, // optional, default is 500
});
```

#### Resource Management

**`getAccountResources(account)`**

Gets the account resources including CPU, NET, and RAM information.

If name is empty, the default sub-account's name obtained during initialization is used.

```typescript
const resources = await dexKit.getAccountResources("name");
// Returns:
// {
//   cpuMax: string,
//   cpuAvailable: string,
//   netMax: string,
//   netAvailable: string,
//   ramQuota: string,
//   ramUsed: string
// }
```

**`powerup(params)`**

Powers up the account with CPU and NET resources.

```typescript
const txID = await dexKit.powerup({
  netEOS: 100000, // optional
  cpuEOS: 1000000000, // optional
  maxPayment: 100000, // optional
  days: 1, // optional, defaults to 1 day
});
```

#### Constructor Options

When creating a new DexKit instance, you can provide various configuration options:

```typescript
const dexKit = new DexKit({
  apiKey: "your-api-key",
  secretKey: "your-secret-key",
  enableProxy: true, // optional, defaults to true
  devMode: false, // optional, defaults to false
  apiClientConfig: {
    // HTTP API client configuration
    baseUrl: "https://api-v1.example.com", // optional
    timeout: 30000, // optional
    headers: {
      ["key"]: "value",
    }, // optional
  },
  blockchainRpcClientConfig: {
    // Blockchain RPC client configuration
    chainID: "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906", // optional
    rpcUrl: "https://spring-rpc.1dex.com", // optional
  },
  powerupConfig: {
    // Powerup payer account
    payer: "powerup.account", // optional
    permission: "active", // optional
    privateKey: "powerup-private-key", // optional
  },
});
```

### HTTP API Client

The DexKit instance exposes an `httpApiClient` property that provides access to various API endpoints for retrieving market data and account information.

#### Account and Balance

**`getAccount()`**

Retrieves account information.

```typescript
const account = await dexKit.httpApiClient.getAccount();
```

**`getBalance()`**

Retrieves the user's balance information.

```typescript
const balance = await dexKit.httpApiClient.getBalance();
```

#### Market Data

**`getAllPools(params?)`**

Retrieves all available trading pools.

```typescript
// Get all pools
const allPools = await dexKit.httpApiClient.getAllPools();

// Get pools filtered by base or quote coin
const filteredPools = await dexKit.httpApiClient.getAllPools({
  baseCoin: "EOS",
  quoteCoin: "USDT",
});
```

**`getPoolInfo(symbolOrPoolID)`**

Retrieves detailed information about a specific pool.

```typescript
// Get pool by ID
const poolInfo = await dexKit.httpApiClient.getPoolInfo(1);
```

**`getDepth(params)`**

Retrieves order book depth data for a specific pool.

```typescript
const depth = await dexKit.httpApiClient.getDepth({
  id: 1,
  precision: 0.001,
  limit: 20, // Optional
});
```

**`getKline(params)`**

Retrieves kline/candlestick data for a specific pool.

```typescript
const klineData = await dexKit.httpApiClient.getKline({
  poolID: 1,
  period: "1h", // Options: '1min', '5min', '15min', '30min', '1h', '4h', '1d', '1w', '1M'
  startTime: 1609459200, // Optional: Unix timestamp in seconds
  endTime: 1609545600, // Optional: Unix timestamp in seconds
});
```

**`getLatestTrades(params)`**

Retrieves the latest trades for a specific pool.

```typescript
const latestTrades = await dexKit.httpApiClient.getLatestTrades({
  poolID: 1,
  limit: 20, // Optional
});
```

#### Order Management

**`getOpenOrders(params)`**

Retrieves open (active) orders.

```typescript
const openOrders = await dexKit.httpApiClient.getOpenOrders({
  poolID: 1,
  side: "buy", // Optional: 'buy' or 'sell'
});
```

**`getOrderHistory(params)`**

Retrieves order history.

```typescript
const orderHistory = await dexKit.httpApiClient.getOrderHistory({
  poolID: 1,
  side: "buy", // Optional: 'buy' or 'sell'
  type: "limit", // Optional: 'limit' or 'market'
  status: "full_filled", // Optional: 'canceled', 'full_filled', 'partially_filled'
});
```

**`getOrderDetail(params)`**

Retrieves detailed information about a specific order.

```typescript
const orderDetail = await dexKit.httpApiClient.getOrderDetail({
  poolID: 1,
  orderID: 1,
  side: "buy", // Required: 'buy' or 'sell'
});
```

**`getOrderDetailByCid(cid)`**

Retrieves detailed information about a specific order by client order id.

```typescript
const orderDetail = await dexKit.httpApiClient.getOrderDetailByCid(cid);
```

#### Token Information

**`getSupportedTokens()`**

Retrieves all supported tokens.

```typescript
const tokens = await dexKit.httpApiClient.getSupportedTokens();
```

**`getTokenInfo(token)`**

Retrieves detailed information about a specific token.

```typescript
const tokenInfo = await dexKit.httpApiClient.getTokenInfo("EOS");
```

### Complete Trading Example

```typescript
import { DexKit, ETradeSide, EOrderType } from "1dex-js-sdk";

async function tradingExample() {
  // Initialize SDK
  const dexKit = new DexKit({
    apiKey: "YOUR_API_KEY",
    secretKey: "YOUR_SECRET_KEY",
    apiClientConfig: {
      baseUrl: "https://api-v1.example.com", // Optional
    },
    blockchainRpcClientConfig: {
      chainID: "YOUR_CHAIN_ID", // Default: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
      rpcUrl: "https://rpc.example.com", // Default: 'https://spring-rpc.1dex.com'
    },
  });

  await dexKit.initialize();

  // Get available pools
  const pools = await dexKit.httpApiClient.getAllPools();
  const poolID = pools[0].pool_id;

  // Check market depth
  const depth = await dexKit.httpApiClient.getDepth({
    id: poolID,
    precision: 0.001,
  });

  // Place a limit buy order
  const txID = await dexKit.placeLimitOrder({
    poolID,
    side: ETradeSide.BUY,
    orderType: EOrderType.NO_RESTRICTION,
    amount: "10.0000",
    price: depth.bids[0][0], // Using the best bid price
  });

  console.log(`Order placed with transaction ID: ${txID}`);

  // Check open orders
  const openOrders = await dexKit.httpApiClient.getOpenOrders({
    poolID,
    side: "buy",
  });

  if (openOrders.length > 0) {
    // Cancel the first open order
    const orderID = openOrders[0].order_id;

    const cancelTxID = await dexKit.cancelOrder({
      poolID,
      orderID,
      side: ETradeSide.BUY,
    });

    console.log(`Order cancelled with transaction ID: ${cancelTxID}`);
  }
}

tradingExample().catch(console.error);
```

### Powerup Example

```typescript
import { DexKit } from "1dex-js-sdk";

const dexKit = new DexKit({
  apiKey: "",
  secretKey: "",
  enableProxy: false,
  powerupConfig: {
    payer: "",
    permission: "",
    privateKey: "",
  },
});

const MAX_RETRY_COUNT = 3; // 3 times
const CHECK_INTERVAL = 1000; // 1 second
const POWERUP_AVAILABLE_RATE = 0.1; // 10%

const powerupExample = async () => {
  await dexKit.initialize();

  const checkAndPowerup = async () => {
    let retryCount = 0;

    const tryPowerup = async () => {
      try {
        await dexKit.powerup();
        console.log("Powerup successful");
        return true;
      } catch (error) {
        console.error(`Powerup attempt ${retryCount + 1} failed:`, error);
        return false;
      }
    };

    while (true) {
      try {
        const resources = await dexKit.getAccountResources();

        const cpuAvailable = parseFloat(resources.cpuAvailable);
        const cpuMax = parseFloat(resources.cpuMax);
        const netAvailable = parseFloat(resources.netAvailable);
        const netMax = parseFloat(resources.netMax);

        console.log(
          `Current resources - CPU: ${((cpuAvailable / cpuMax) * 100).toFixed(
            2
          )}%, NET: ${((netAvailable / netMax) * 100).toFixed(2)}%`
        );

        if (cpuMax === 0 || netMax === 0) {
          retryCount = 0;
          while (retryCount < MAX_RETRY_COUNT) {
            const result = await tryPowerup();
            if (result) break;
            retryCount++;
            if (retryCount < MAX_RETRY_COUNT) {
              await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait 1s before retry
            }
          }
        } else {
          const cpuRate = cpuAvailable / cpuMax;
          const netRate = netAvailable / netMax;

          if (
            cpuRate < POWERUP_AVAILABLE_RATE ||
            netRate < POWERUP_AVAILABLE_RATE
          ) {
            retryCount = 0;
            while (retryCount < MAX_RETRY_COUNT) {
              const result = await tryPowerup();
              if (result) break;
              retryCount++;
              if (retryCount < MAX_RETRY_COUNT) {
                await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait 1s before retry
              }
            }
          }
        }
      } catch (error) {
        console.error("Error checking resources:", error);
      }

      // Wait for the next check interval
      await new Promise((resolve) => setTimeout(resolve, CHECK_INTERVAL));
    }
  };

  // Start the continuous monitoring
  await checkAndPowerup();
};

powerupExample();
```

### Error Handling

The SDK uses standardized error handling. Errors thrown by the SDK include detailed information about what went wrong. It's recommended to use try-catch blocks when interacting with the SDK:

```typescript
try {
  await dexKit.placeLimitOrder({
    poolID: 1,
    side: ETradeSide.BUY,
    orderType: EOrderType.NO_RESTRICTION,
    amount: "10.0000",
    price: "0.5000",
  });
} catch (error) {
  console.error("Error placing order:", error.message);
}
```


# Overview

1Dex API V1 provides a set of RESTful API interfaces for accessing the core functionalities of the exchange, including market data, user account information, trading operations, and more. These interfaces follow a unified request and response format for easy integration by developers.

## Basic Information

* **Base Path**: `/api/v1`
* **Supported Protocols**: HTTPS
* **Content Type**: application/json
* **Mainnet Host**: <https://api-v1.1dex.com>

## Authentication

Some APIs require authentication to access. Authentication uses an API key approach:

```
Authorization: <API_KEY>
```

Add the API key to the HTTP request header for authentication.

## Response Structure

All API responses use a unified JSON format:

```json
{
  "code": 0,         // Response status code, 0 means success, non-zero means error
  "message": "",     // Error message, empty when successful
  "data": {},        // Response data, structure varies by endpoint
  "meta": {}         // Metadata, such as pagination information
}
```

### Response Status Codes

| Status Code | Description             |
| ----------- | ----------------------- |
| 0           | Request successful      |
| 400         | Request parameter error |
| 401         | Unauthorized            |
| 403         | No permission           |
| 500         | Internal server error   |

### List Query Response

For endpoints that return list data, the `meta` field will contain total count information:

```json
{
  "code": 0,
  "message": "",
  "data": [{}, {}],
  "meta": {
    "total": 100
  }
}
```

## Error Codes

| Error Code | Description                           |
| ---------- | ------------------------------------- |
| 400        | Request parameter error               |
| 401        | Unauthorized or authentication failed |
| 403        | No operation permission               |
| 404        | Resource not found                    |
| 429        | Too many requests                     |
| 500        | Internal server error                 |

## Order Status Codes

| Status Code | Description      |
| ----------- | ---------------- |
| 0           | Unfilled         |
| 1           | Partially filled |
| 2           | Fully filled     |
| 3           | Canceled         |
| 4           | Rejected         |


# General Endpoints

## Ping

> Ping

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/ping":{"get":{"tags":["General endpoints"],"summary":"Ping","description":"Ping","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"object","properties":{"timestamp":{"type":"integer","description":"timestamp"}}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}}}}}
```

## Get system information

> Get system information

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/system-info":{"get":{"tags":["General endpoints"],"summary":"Get system information","description":"Get system information","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.RespSystemInfo"}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.RespSystemInfo":{"type":"object","properties":{"app_contract":{"type":"string"},"pay_eos_account":{"type":"string"},"token_contract":{"type":"string"},"version":{"type":"string"}}}}}}
```

## List all trading pools

> Get a list of all trading pools

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/pools":{"get":{"tags":["General endpoints"],"summary":"List all trading pools","description":"Get a list of all trading pools","parameters":[{"name":"base_coin","in":"query","description":"base coin","schema":{"type":"string"}},{"name":"quote_coin","in":"query","description":"quote coin","schema":{"type":"string"}}],"responses":{"200":{"description":"pool info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.PoolStats"}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.PoolStats":{"type":"object","properties":{"base_coin":{"type":"string"},"base_coin_precision":{"type":"integer"},"change":{"type":"string"},"change_rate":{"type":"number"},"high":{"type":"string"},"last_price":{"type":"string"},"low":{"type":"string"},"pool_id":{"type":"integer"},"price_precision":{"type":"integer"},"quote_coin":{"type":"string"},"quote_coin_precision":{"type":"integer"},"symbol":{"type":"string"},"trades":{"type":"integer"},"turnover":{"type":"string"},"updated_at":{"type":"string"},"volume":{"type":"string"}}}}}}
```

## Get pool details

> Get detailed information about a specific trading pool

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/pools/{symbolOrId}":{"get":{"tags":["General endpoints"],"summary":"Get pool details","description":"Get detailed information about a specific trading pool","parameters":[{"name":"symbolOrId","in":"path","description":"pool symbol or pool id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.Pool"}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Pool":{"type":"object","properties":{"asking_time":{"type":"string"},"base_coin":{"type":"string"},"base_coin_precision":{"type":"integer"},"base_contract":{"type":"string"},"base_symbol":{"type":"string"},"maker_fee_rate":{"type":"number"},"max_flct":{"type":"integer"},"min_amount":{"type":"string"},"pool_id":{"type":"integer"},"pool_stats":{"$ref":"#/components/schemas/entity.PoolStats"},"price_precision":{"type":"integer"},"quote_coin":{"type":"string"},"quote_coin_precision":{"type":"integer"},"quote_contract":{"type":"string"},"quote_symbol":{"type":"string"},"status":{"type":"integer"},"symbol":{"type":"string"},"taker_fee_rate":{"type":"number"},"trading_time":{"type":"string"}}},"entity.PoolStats":{"type":"object","properties":{"base_coin":{"type":"string"},"base_coin_precision":{"type":"integer"},"change":{"type":"string"},"change_rate":{"type":"number"},"high":{"type":"string"},"last_price":{"type":"string"},"low":{"type":"string"},"pool_id":{"type":"integer"},"price_precision":{"type":"integer"},"quote_coin":{"type":"string"},"quote_coin_precision":{"type":"integer"},"symbol":{"type":"string"},"trades":{"type":"integer"},"turnover":{"type":"string"},"updated_at":{"type":"string"},"volume":{"type":"string"}}}}}}
```

## Get support tokens

> Get support tokens

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/tokens":{"get":{"tags":["General endpoints"],"summary":"Get support tokens","description":"Get support tokens","responses":{"200":{"description":"token list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.Token"}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Token":{"type":"object","properties":{"decimals":{"type":"integer"},"eos_contract":{"type":"string"},"exsat_decimals":{"type":"integer"},"exsat_token_address":{"type":"string"},"icon_url":{"type":"string"},"info":{"$ref":"#/components/schemas/entity.TokenInfo"},"name":{"type":"string"},"support_chain":{"type":"array","items":{"$ref":"#/components/schemas/entity.Chain"}},"symbol":{"type":"string"}}},"entity.TokenInfo":{"type":"object","properties":{"circulating_supply":{"type":"string"},"fully_diluted_market_cap":{"type":"string"},"historical_high":{"type":"string"},"historical_high_date":{"type":"string"},"historical_low":{"type":"string"},"historical_low_date":{"type":"string"},"intro":{"type":"string"},"issue_date":{"type":"string"},"links":{"type":"array","items":{"$ref":"#/components/schemas/entity.TokenLink"}},"market_capitalization":{"type":"string"},"market_dominance":{"type":"string"},"maximum_supply":{"type":"string"},"rank":{"type":"string"},"total_supply":{"type":"string"},"volume":{"type":"string"},"volume_div_market_cap":{"type":"string"}}},"entity.TokenLink":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string"}}},"entity.Chain":{"type":"object","properties":{"chain_id":{"type":"integer"},"chain_name":{"type":"string"},"exsat_withdraw_fee":{"type":"string"},"min_deposit_amount":{"type":"string"},"min_withdraw_amount":{"type":"string"},"permission_id":{"type":"integer"},"withdraw_fee":{"type":"string"}}}}}}
```

## Get token info

> Get token info

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/token/{symbol}":{"get":{"tags":["General endpoints"],"summary":"Get token info","description":"Get token info","parameters":[{"name":"symbol","in":"path","description":"coin symbol,ps BTC","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"token info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.Token"}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Token":{"type":"object","properties":{"decimals":{"type":"integer"},"eos_contract":{"type":"string"},"exsat_decimals":{"type":"integer"},"exsat_token_address":{"type":"string"},"icon_url":{"type":"string"},"info":{"$ref":"#/components/schemas/entity.TokenInfo"},"name":{"type":"string"},"support_chain":{"type":"array","items":{"$ref":"#/components/schemas/entity.Chain"}},"symbol":{"type":"string"}}},"entity.TokenInfo":{"type":"object","properties":{"circulating_supply":{"type":"string"},"fully_diluted_market_cap":{"type":"string"},"historical_high":{"type":"string"},"historical_high_date":{"type":"string"},"historical_low":{"type":"string"},"historical_low_date":{"type":"string"},"intro":{"type":"string"},"issue_date":{"type":"string"},"links":{"type":"array","items":{"$ref":"#/components/schemas/entity.TokenLink"}},"market_capitalization":{"type":"string"},"market_dominance":{"type":"string"},"maximum_supply":{"type":"string"},"rank":{"type":"string"},"total_supply":{"type":"string"},"volume":{"type":"string"},"volume_div_market_cap":{"type":"string"}}},"entity.TokenLink":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string"}}},"entity.Chain":{"type":"object","properties":{"chain_id":{"type":"integer"},"chain_name":{"type":"string"},"exsat_withdraw_fee":{"type":"string"},"min_deposit_amount":{"type":"string"},"min_withdraw_amount":{"type":"string"},"permission_id":{"type":"integer"},"withdraw_fee":{"type":"string"}}}}}}
```


# Market Data Endpoints

### V2 Aggregated Endpoints (Recommended)

With the introduction of AMM V2, we now provide aggregated endpoints that combine both spot engine and AMM liquidity. These V2 endpoints are recommended for new integrations as they provide more comprehensive market data.

#### V1 vs V2 Interface Differences

| Feature            | V1 Interface            | V2 Interface                     |
| ------------------ | ----------------------- | -------------------------------- |
| **Data Source**    | Spot engine only        | Spot engine + AMM aggregated     |
| **Liquidity**      | Order book only         | Order book + AMM liquidity       |
| **Trades**         | Spot engine trades only | All trades (spot + AMM)          |
| **Klines**         | Spot engine volume only | Combined volume from all sources |
| **Depth**          | Order book depth only   | Merged depth with AMM liquidity  |
| **Performance**    | Standard                | Optimized with AMM integration   |
| **Recommendation** | Legacy support          | **Use V2 for new integrations**  |

**Key Advantages of V2 Interfaces**:

* **Enhanced Liquidity**: Includes AMM pool liquidity mapped to order book
* **Complete Market View**: Shows all trading activity (spot + AMM)
* **Better Price Discovery**: AMM provides additional price levels
* **Unified Data**: Single endpoint for comprehensive market data
* **Future-Proof**: Designed for the new AMM V2 architecture

**Migration Guide**:

* Replace `/klines` with `/klines/v2`
* Replace `/depth` with `/depth/v2`
* Replace `/latest-trades` with `/latest-trades/v2`
* Response format remains the same, but data includes AMM sources

## Get depth

> Get order book by pool id

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/depth":{"get":{"tags":["Market Data endpoints"],"summary":"Get depth","description":"Get order book by pool id","parameters":[{"name":"pool_id","in":"query","description":"pool_id","required":true,"schema":{"type":"string"}},{"name":"precision","in":"query","description":"0.00000001 ~ 10000","schema":{"type":"string"}},{"name":"limit","in":"query","description":"limit","schema":{"type":"integer"}}],"responses":{"200":{"description":"order depth","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.Depth"}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Depth":{"type":"object","properties":{"asks":{"type":"array","items":{"type":"array","items":{"type":"string"}}},"bids":{"type":"array","items":{"type":"array","items":{"type":"string"}}},"pool_id":{"type":"integer"},"precision":{"type":"string"},"timestamp":{"type":"integer"}}}}}}
```

## Get kline data

> Get kline data by pool id and interval

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/klines":{"get":{"tags":["Market Data endpoints"],"summary":"Get kline data","description":"Get kline data by pool id and interval","parameters":[{"name":"pool_id","in":"query","description":"pool id","required":true,"schema":{"type":"string"}},{"name":"interval","in":"query","description":"interval","required":true,"schema":{"type":"string","enum":["1m","5m","15m","30m","1h","4h","1d","1w","1M"]}},{"name":"start","in":"query","description":"start timestamp","schema":{"type":"integer"}},{"name":"end","in":"query","description":"end timestamp","schema":{"type":"integer"}}],"responses":{"200":{"description":"kline data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.Kline"}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Kline":{"type":"object","properties":{"close":{"type":"number"},"count":{"type":"integer"},"high":{"type":"number"},"interval":{"type":"string"},"low":{"type":"number"},"open":{"type":"number"},"pool_id":{"type":"integer"},"timestamp":{"type":"string"},"turnover":{"type":"number"},"volume":{"type":"number"}}}}}}
```

## Get latest trades

> Get latest trades

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"paths":{"/api/v1/latest-trades":{"get":{"tags":["Market Data endpoints"],"summary":"Get latest trades","description":"Get latest trades","parameters":[{"name":"pool_id","in":"query","description":"pool_id","schema":{"type":"string"}},{"name":"limit","in":"query","description":"limit count","schema":{"type":"integer"}}],"responses":{"200":{"description":"trade list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.Trade"}}}}}}}}}}},"components":{"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Trade":{"type":"object","properties":{"buyer":{"type":"string"},"pool_id":{"type":"integer"},"price":{"type":"string"},"quantity":{"type":"string"},"seller":{"type":"string"},"side":{"$ref":"#/components/schemas/entity.TradeSide"},"traded_at":{"type":"string"}}},"entity.TradeSide":{"type":"string","enum":["buy","sell"]}}}}
```


# Account Endpoints

## Get user info

> Get user info

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.RespV1UserInfo":{"type":"object","properties":{"eos_account":{"type":"string"},"parent_eos_account":{"type":"string"},"permission":{"type":"string"}}}}},"paths":{"/api/v1/info":{"get":{"tags":["Account Endpoints"],"summary":"Get user info","description":"Get user info","responses":{"200":{"description":"user info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.RespV1UserInfo"}}}}}}}}}}}
```

## Get user balances

> Get user balances

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.SubAccountBalance":{"type":"object","properties":{"balance":{"type":"string"},"coin":{"type":"string"},"locked":{"type":"string"},"locks":{"type":"array","items":{"$ref":"#/components/schemas/entity.LockBalance"}},"usdt_price":{"type":"string"}}},"entity.LockBalance":{"type":"object","properties":{"balance":{"type":"string"},"pool_id":{"type":"integer"},"pool_symbol":{"type":"string"}}}}},"paths":{"/api/v1/balances":{"get":{"tags":["Account Endpoints"],"summary":"Get user balances","description":"Get user balances","responses":{"200":{"description":"user balances","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.SubAccountBalance"}}}}}}}}}}}}
```

## Get history orders

> Get history orders

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Order":{"type":"object","properties":{"avg_price":{"type":"string"},"base_coin_precision":{"type":"integer"},"executed_amount":{"type":"string"},"filled_total":{"type":"string"},"history":{"type":"boolean"},"id":{"type":"string"},"order_amount":{"type":"string"},"order_cid":{"type":"string"},"order_id":{"type":"integer"},"order_price":{"type":"string"},"order_time":{"type":"string"},"order_total":{"type":"string"},"permission":{"type":"string"},"pool_base_coin":{"type":"string"},"pool_id":{"type":"integer"},"pool_quote_coin":{"type":"string"},"pool_symbol":{"type":"string"},"quote_coin_precision":{"type":"integer"},"side":{"type":"integer","description":"0 buy 1 sell"},"status":{"type":"integer","description":"0 open 1partially_filled 2full_filled 3.canceled"},"trader":{"type":"string"},"type":{"type":"integer","description":"0 market 1 limit"},"unread":{"type":"boolean"}}}}},"paths":{"/api/v1/history-orders":{"get":{"tags":["Account Endpoints"],"summary":"Get history orders","description":"Get history orders","parameters":[{"name":"pool_id","in":"query","description":"pool_id","schema":{"type":"string"}},{"name":"side","in":"query","description":"0 buy 1 sell","schema":{"type":"string"}},{"name":"type","in":"query","description":"0 market 1limit","schema":{"type":"string"}},{"name":"status","in":"query","description":"status","schema":{"type":"string"}}],"responses":{"200":{"description":"history orders","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.Order"}}}}}}}}}}}}
```

## Get open orders

> Get open orders

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.OpenOrder":{"type":"object","properties":{"avg_price":{"type":"string"},"base_coin_precision":{"type":"integer"},"executed_amount":{"type":"string"},"id":{"type":"string"},"order_amount":{"type":"string"},"order_cid":{"type":"string"},"order_id":{"type":"integer"},"order_price":{"type":"string"},"order_time":{"type":"string"},"order_total":{"type":"string"},"pool_base_coin":{"type":"string"},"pool_id":{"type":"integer"},"pool_quote_coin":{"type":"string"},"pool_symbol":{"type":"string"},"quote_coin_precision":{"type":"integer"},"side":{"type":"integer","description":"0 buy 1 sell"},"trader":{"type":"string"},"type":{"type":"integer","description":"0 market 1 limit"}}}}},"paths":{"/api/v1/open-orders":{"get":{"tags":["Account Endpoints"],"summary":"Get open orders","description":"Get open orders","parameters":[{"name":"pool_id","in":"query","description":"pool_id","schema":{"type":"string"}},{"name":"side","in":"query","description":"0 buy 1 sell","schema":{"type":"string"}}],"responses":{"200":{"description":"open order list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.OpenOrder"}}}}}}}}}}}}
```

## Get history order detail

> Get history order detail

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.OrderDetail":{"type":"object","properties":{"avg_price":{"type":"string"},"base_coin_precision":{"type":"integer"},"executed_amount":{"type":"string"},"filled_total":{"type":"string"},"history":{"type":"boolean"},"id":{"type":"string"},"order_amount":{"type":"string"},"order_cid":{"type":"string"},"order_id":{"type":"integer"},"order_price":{"type":"string"},"order_time":{"type":"string"},"order_total":{"type":"string"},"permission":{"type":"string"},"pool_base_coin":{"type":"string"},"pool_id":{"type":"integer"},"pool_quote_coin":{"type":"string"},"pool_symbol":{"type":"string"},"quote_coin_precision":{"type":"integer"},"side":{"type":"integer","description":"0 buy 1 sell"},"status":{"type":"integer","description":"0 open 1partially_filled 2 full_filled 3.canceled"},"trader":{"type":"string"},"trades":{"type":"array","items":{"$ref":"#/components/schemas/entity.TradeDetail"}},"type":{"type":"integer","description":"0 market 1 limit"},"unread":{"type":"boolean"}}},"entity.TradeDetail":{"type":"object","properties":{"base_coin":{"type":"string"},"base_quantity":{"type":"string"},"global_seq":{"type":"integer"},"maker":{"type":"string"},"maker_fee":{"type":"string"},"maker_order_cid":{"type":"string"},"maker_order_id":{"type":"integer"},"maker_permission":{"type":"string"},"pool_id":{"type":"integer"},"price":{"type":"string"},"quote_coin":{"type":"string"},"quote_quantity":{"type":"string"},"taker":{"type":"string"},"taker_fee":{"type":"string"},"taker_is_bid":{"type":"boolean"},"taker_order_cid":{"type":"string"},"taker_order_id":{"type":"integer"},"taker_permission":{"type":"string"},"timestamp":{"type":"string"},"tx_id":{"type":"string"}}}}},"paths":{"/api/v1/orders/{id}":{"get":{"tags":["Account Endpoints"],"summary":"Get history order detail","description":"Get history order detail","parameters":[{"name":"id","in":"path","description":"pool_id+order_id+side,ps:0-1-0 pool_id = 0,order_id = 1,side = buy","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"history order detail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.OrderDetail"}}}}}}}}}}}
```

## Get order by client order ID

> Get order by client order ID (order\_cid)

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.Order":{"type":"object","properties":{"avg_price":{"type":"string"},"base_coin_precision":{"type":"integer"},"executed_amount":{"type":"string"},"filled_total":{"type":"string"},"history":{"type":"boolean"},"id":{"type":"string"},"order_amount":{"type":"string"},"order_cid":{"type":"string"},"order_id":{"type":"integer"},"order_price":{"type":"string"},"order_time":{"type":"string"},"order_total":{"type":"string"},"permission":{"type":"string"},"pool_base_coin":{"type":"string"},"pool_id":{"type":"integer"},"pool_quote_coin":{"type":"string"},"pool_symbol":{"type":"string"},"quote_coin_precision":{"type":"integer"},"side":{"type":"integer","description":"0 buy 1 sell"},"status":{"type":"integer","description":"0 open 1partially_filled 2full_filled 3.canceled"},"trader":{"type":"string"},"type":{"type":"integer","description":"0 market 1 limit"},"unread":{"type":"boolean"}}}}},"paths":{"/api/v1/orders/client-id/{id}":{"get":{"tags":["Account Endpoints"],"summary":"Get order by client order ID","description":"Get order by client order ID (order_cid)","parameters":[{"name":"id","in":"path","description":"Client order ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"order","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"$ref":"#/components/schemas/entity.Order"}}}}}}}}}}}
```

## Get trades by subaccount

> Get recent trades for the authenticated subaccount

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.TradeDetail":{"type":"object","properties":{"base_coin":{"type":"string"},"base_quantity":{"type":"string"},"global_seq":{"type":"integer"},"maker":{"type":"string"},"maker_fee":{"type":"string"},"maker_order_cid":{"type":"string"},"maker_order_id":{"type":"integer"},"maker_permission":{"type":"string"},"pool_id":{"type":"integer"},"price":{"type":"string"},"quote_coin":{"type":"string"},"quote_quantity":{"type":"string"},"taker":{"type":"string"},"taker_fee":{"type":"string"},"taker_is_bid":{"type":"boolean"},"taker_order_cid":{"type":"string"},"taker_order_id":{"type":"integer"},"taker_permission":{"type":"string"},"timestamp":{"type":"string"},"tx_id":{"type":"string"}}}}},"paths":{"/api/v1/trades":{"get":{"tags":["Account Endpoints"],"summary":"Get trades by subaccount","description":"Get recent trades for the authenticated subaccount","parameters":[{"name":"limit","in":"query","description":"limit count (default 50, max 100)","schema":{"type":"integer"}},{"name":"startTime","in":"query","description":"filter trades after this timestamp (Unix timestamp in seconds)","schema":{"type":"integer"}},{"name":"endTime","in":"query","description":"filter trades before this timestamp (Unix timestamp in seconds)","schema":{"type":"integer"}},{"name":"global_seq","in":"query","description":"filter trades with global sequence number greater than this value","schema":{"type":"integer"}},{"name":"sort","in":"query","description":"sort direction for timestamp (asc or desc, default desc)","schema":{"type":"string","enum":["asc","desc"]}}],"responses":{"200":{"description":"trade detail list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.TradeDetail"}}}}}}}}}}}}
```

## Get subaccount transfers

> Get transfer records between subaccount and main account

```json
{"openapi":"3.0.1","info":{"title":"1dex api v1","version":"1.0"},"servers":[{"url":"https://api-v1.1dex.com"},{"url":"https://api-test-v1.1dex.com"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"Authorization","in":"header"}},"schemas":{"api.Response":{"type":"object","properties":{"code":{"type":"integer","format":"uint32","description":"Response status code"},"message":{"type":"string","description":"Response message"},"data":{"description":"Response data payload (can be any type)"},"meta":{"type":"object","additionalProperties":true,"description":"Additional metadata with dynamic keys"}}},"entity.SubAccountTransfer":{"type":"object","properties":{"amount":{"type":"string","description":"transfer amount"},"contract":{"type":"string","description":"token contract address"},"symbol":{"type":"string","description":"token symbol"},"from":{"type":"string","description":"sender address"},"to":{"type":"string","description":"receiver address"},"tx_id":{"type":"string","description":"transaction ID"},"side":{"type":"string","description":"transfer direction (in/out)"},"sid":{"type":"string","description":"subaccount ID"},"name":{"type":"string","description":"subaccount name"},"created_at":{"type":"string","format":"date-time","description":"transfer creation time"}}}}},"paths":{"/api/v1/transfers":{"get":{"tags":["Account Endpoints"],"summary":"Get subaccount transfers","description":"Get transfer records between subaccount and main account","parameters":[{"name":"limit","in":"query","description":"limit count","schema":{"type":"integer"}},{"name":"startTime","in":"query","description":"start time in Unix timestamp format (seconds since epoch)","schema":{"type":"integer"}},{"name":"endTime","in":"query","description":"end time in Unix timestamp format (seconds since epoch)","schema":{"type":"integer"}},{"name":"transfer_id","in":"query","description":"filter transfers with id greater than this value","schema":{"type":"integer"}},{"name":"sort","in":"query","description":"sort direction for created_at (asc or desc, default desc)","schema":{"type":"string","enum":["asc","desc"]}}],"responses":{"200":{"description":"transfer records with pagination","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api.Response","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/entity.SubAccountTransfer"}}}}}}}}}}}}
```


# Overview

We use Socket.IO v4 protocol for WebSocket communication.

### Connection Information

* **WebSocket URL**:
  * for sandbox: `https://wss-test.1dex.com/socket.io`
  * for production: `https://wss.1dex.com/socket.io`
* **Protocol**: Socket.IO v4
* **Ping Interval**: 10 seconds
* **Ping Timeout**: 5 seconds
* **Connection Timeout**: 5 seconds

### Authentication Flow

#### 1. User Authentication

Users can authenticate by sending the `authenticate` event:

```javascript
socket.emit('authenticate', 'api-key');

socket.on('authenticated', (response) => {
    console.log(response);
    // response:
    // {
    //     "status": "success",
    //     "account": "account"
    // }
});
```

#### 2. Unauthenticate

```javascript
socket.emit('unauthenticate', 'api-key');
```


# Subscription Interface

### Events

#### 1. Kline Data Subscription

**1.1 Kline Data Subscription (v1 - Spot Only, Original)**

```javascript
socket.emit('subscribe_kline', poolId, interval);

socket.emit('subscribe_kline', 1, '1m');
```

*Returns only spot engine kline data, excluding AMM swap klines. This is the original behavior and remains the default.*

**1.2 Kline Data Subscription v2 (Aggregated)**

```javascript
socket.emit('subscribe_kline_v2', poolId, interval);

socket.emit('subscribe_kline_v2', 1, '1m');
```

*Returns aggregated kline data (spot + AMM) including AMM swap klines. This is the new enhanced version.*

#### 2. Depth Data Subscription

**2.1 Depth Data Subscription (v1 - Spot Only, Original)**

```javascript
socket.emit('subscribe_depth', poolId, precision);

socket.emit('subscribe_depth', 1, '0.00000001');
```

*Returns only spot order book depth data, excluding AMM liquidity. This is the original behavior and remains the default.*

**2.2 Depth Data Subscription v2 (Aggregated)**

```javascript
socket.emit('subscribe_depth_v2', poolId, precision);

socket.emit('subscribe_depth_v2', 1, '0.00000001');
```

*Returns aggregated depth data (spot + AMM) when AMM pools are available. This is the new enhanced version.*

#### 3.Pool Stats Data Subscription

```javascript
socket.emit('subscribe_pool_stats', poolId);

socket.emit('subscribe_pool_stats', 1);
```

#### All Pools Stats Data Subscription

```javascript
socket.emit('subscribe_all_pool_stats');
```

#### 12. Unsubscribe

```javascript
socket.emit('unsubscribe', subscriptionType, poolId, interval, precision);

socket.emit('unsubscribe', 'kline', 1, '1m');
socket.emit('unsubscribe', 'kline_v2', 1, '1m');
socket.emit('unsubscribe', 'perp_kline', 1, '1m');

socket.emit('unsubscribe', 'depth', 1, '0.00000001');
socket.emit('unsubscribe', 'depth_v2', 1, '0.00000001');
socket.emit('unsubscribe', 'perp_depth', 1, '0.00000001');

socket.emit('unsubscribe', 'trades', 1);
socket.emit('unsubscribe', 'trades_v2', 1);
socket.emit('unsubscribe', 'perp_trades', 1);

socket.emit('unsubscribe', 'amm_swap', 1);

socket.emit('unsubscribe', 'pool_stats', 1);
socket.emit('unsubscribe', 'perp_pool_stats', 1);

socket.emit('unsubscribe', 'perp_price', 1);
```

#### Unsubscribe All

```javascript
socket.emit('unsubscribe_all');
```

#### Unsubscribe All Kline

```javascript
socket.emit('unsubscribe_all_kline');
```

#### Unsubscribe All Depth

```javascript
socket.emit('unsubscribe_all_depth');
```

#### Unsubscribe All Pool Stats

```javascript
socket.emit('unsubscribe_all_pool_stats');
```

### Subscription Response

When successfully subscribing to a topic, the `subscribed` event is received:

```javascript
socket.on('subscribed', (response) => {
    console.log(response);
});
```


# Listen

### Listen Kline Data

```javascript
socket.on('kline', (data) => {});
```

Payload:

```json
{
  "pool_id": 1,
  "interval": "1m",
  "timestamp": 1234567890,
  "open": 100.5,
  "high": 101.5,
  "low": 99.5,
  "close": 100.8,
  "volume": 1000.5,
  "turnover": 100500.5,
  "count": 100
}
```

#### Listen Depth Data

```javascript
socket.on('depth', (data) => {});
```

Payload:

```json
{
  "pool_id": 1,
  "timestamp": 1234567890,
  "bids": [
      ["100.5", "10.5"],  // [price, amount]
      ["100.4", "15.2"]
  ],
  "asks": [
      ["100.6", "5.5"],
      ["100.7", "8.2"]
  ]
  "precision": "0.000000001"
}
```

#### Listen Trade Data

```javascript
socket.on('trade', (data) => {});
```

Payload:

```json
{
  "pool_id": 1,
  "buyer": "account1",
  "seller": "account2",
  "quantity": "10.5",
  "price": "100.5",
  "traded_at": 1234567890,
  "side": "buy"  // "buy" or "sell"
}
```

#### Listen Order Update

```javascript
socket.on('order_update', (data) => {});
```

Payload:

```json
{
  "order_time": 1234567890,
  "id": "1-1000-0",
  "order_id": 1,
  "pool_id": 1,
  "pool_symbol": "BTC/USDT",
  "pool_base_coin": "BTC",
  "pool_quote_coin": "USDT",
  "client_order_id": "1000",
  "trader": "account1",
  "side": 0,
  "type": 1,
  "order_price": "100.5",
  "avg_price": "100.5",
  "order_amount": "10.5",
  "executed_amount": "10.5",
  "filled_total": "100.5",
  "status": 0,
  "base_coin_precision": 8,
  "quote_coin_precision": 8
}
```

#### Listen Pool Stats

```javascript
socket.on('pool_stats', (data) => {});
```

Payload:

```json
{
  "pool_id": 1,
  "base_coin": "BTC",
  "quote_coin": "USDT",
  "symbol": "BTC/USDT",
  "last_price": "100.5",
  "change": "1.0",
  "change_rate": 0.01,
  "high": "101.5",
  "low": "99.5",
  "volume": "1000.5",
  "turnover": "100500.5",
  "trades": 100,
  "updated_at": 1234567890
}
```


