# Solar Dex SDK & API

### **Who is Building on the SDK**

The Solar DEX SDK has become a versatile and indispensable tool for projects across the Web3 ecosystem. Developers and platforms are leveraging it to integrate with Solar DEX’s powerful decentralized trading features. Current adopters include:

* **Fighter Horse**: A launchpad and token creation platform utilizing the SDK to simplify token launches and liquidity provisioning.
* **MoonLaunch**: Another launchpad platform integrating the SDK for seamless token creation and liquidity pool setups.
* **Laika**: A Telegram bot built with the SDK to enable token swaps and trading features directly from Telegram.
* **Three DEX Aggregators**: Leveraging the SDK to access Solar DEX’s liquidity pools, optimizing trade routes for users across multiple platforms.
* **A Bridging Platform**: Utilizing the SDK to facilitate cross-chain asset transfers and improve interoperability between networks.

More integrations are on the way, as the SDK continues to power innovative solutions across DeFi and beyond.

***

### **Why the Solar DEX SDK is Important**

The Solar DEX SDK provides developers with a robust, technical foundation to interact seamlessly with the DEX’s infrastructure. By abstracting complex blockchain operations, the SDK enables faster and more efficient development of dApps, tools, and integrations.

#### **Key Features of the SDK**

1. **Streamlined Trading**: Execute token swaps, manage liquidity, and access real-time price data with minimal effort.
2. **Custom Integrations**: Build bespoke trading solutions, such as aggregators, bots, and dashboards, with direct access to Solar DEX’s features.
3. **Scalability**: Designed for high-throughput operations, leveraging the scalability of the Eclipse Network.

#### **What the SDK Does**

The SDK simplifies blockchain interactions by:

* Fetching real-time data on token prices, liquidity, and trading volume.
* Facilitating token swaps and liquidity management directly within your application.
* Providing modular components for rapid development.

***

#### **Steps to Use the SDK:** [**https://github.com/Solar-Studio/solar-sdk**](https://github.com/Solar-Studio/solar-sdk)

1. #### Installation

   ```
   $ yarn add solar-sdk
   ```

   ###
2. ### Trade API

   Solar trade API is the fastest and easiest way to interact with solar liquidity. It allows you to swap for any asset with 2 requests and a signature.

   #### Get quote parameters

   | Parameter   | Type   | Required | Description                                                    |
   | ----------- | ------ | -------- | -------------------------------------------------------------- |
   | inputMint   | string | yes      | Input token mint address                                       |
   | outputMint  | string | yes      | Output token mint address                                      |
   | amount      | number | yes      | Either inputAmount or outputAmount depending on the swap mode. |
   | slippageBps | number | yes      | Slippage tolerance in base points (0.01%).                     |

   #### Post parameters

   | Parameter                     | Type    | Required | Description                                                                                                                                                                                                              |
   | ----------------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
   | version                       | string  | yes      | Use 'V0' for versioned transaction, and 'LEGACY' for legacy transaction (for now only supports 'LEGACY').                                                                                                                |
   | wrapSol                       | boolean | no       | Set to true to accept ETH as `inputToken`.                                                                                                                                                                               |
   | unwrapSol                     | boolean | no       | Set to true to unwrap `wETH` received as `outputToken`.                                                                                                                                                                  |
   | computeUnitPriceMicroLamports | string  | yes      | You can manually set this or use Solar priority fee API to set an automatic amount with `String(data.data.default.h)`. The 'h' stands for high priority. 'vh' for very high and 'm' for medium are also accepted values. |
   | wallet                        | string  | yes      | Public key of the wallet.                                                                                                                                                                                                |
   | inputTokenAccount             | string  | no       | Defaults to ATA (Associated Token Account).                                                                                                                                                                              |
   | outputTokenAccount            | string  | no       | Defaults to ATA (Associated Token Account).                                                                                                                                                                              |

   #### Get quote (<https://api.solarstudios.co/compute/$>) & and define the swap type.

   #### Serialize (<https://api.solarstudios.co/transaction/$>)

   Our apis schema and working is same as raydium's api. For now our api only supports LEGACY tx.

   **Raydium Trade api guide -** [**https://docs.raydium.io/raydium/traders/trade-api**](https://docs.raydium.io/raydium/traders/trade-api)

   **Demo Implimentations -** [**https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/api/swap.ts#L21**](https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/api/swap.ts#L21)

   **BASE API URL -** [**https://api.solarstudios.co**](https://api.solarstudios.co/)

   ## API Endpoints

   ### Main

   Main API endpoints for general information and configuration.

   | Method | Endpoint            | Description                                 |
   | ------ | ------------------- | ------------------------------------------- |
   | GET    | `/main/version`     | UI V3 current version                       |
   | GET    | `/main/rpcs`        | UI RPCs                                     |
   | GET    | `/main/chain-time`  | Chain Time                                  |
   | GET    | `/main/info`        | Total Value Locked (TVL) and 24-hour volume |
   | GET    | `/main/auto-fee`    | Transaction auto fee                        |
   | GET    | `/main/clmm-config` | CLMM Config                                 |
   | GET    | `/main/cpmm-config` | CPMM Config                                 |

   ### Mint

   Endpoints related to mint information.

   | Method | Endpoint      | Description       |
   | ------ | ------------- | ----------------- |
   | GET    | `/mint/list`  | Default Mint List |
   | GET    | `/mint/ids`   | Mint Info         |
   | GET    | `/mint/price` | Mint Price        |

   ### Pools

   Endpoints for pool information, keys, and historical data.

   | Method | Endpoint           | Description             |
   | ------ | ------------------ | ----------------------- |
   | GET    | `/pools/info/ids`  | Pool Info               |
   | GET    | `/pools/info/lps`  | Pool Info by LP Mint    |
   | GET    | `/pools/info/list` | Pool Info List          |
   | GET    | `/pools/info/mint` | Pool Info by Token Mint |
   | GET    | `/pools/key/ids`   | Pool Key                |

   <br>

***

### **API Overview**

The Solar DEX SDK includes a comprehensive **API** for integrating DEX data and functionality into your applications.

#### **API Capabilities**

Solar DEX’s API enables applications to fetch live metrics and data, including:

* **Volume**: Real-time trading volume across all pools.
* **Users**: Number of active traders and unique wallet addresses.
* **Liquidity Added**: Total liquidity added to pools, broken down by token pairs.
* **Other DEX Features**: Pool performance, slippage rates, token price data, and swap analytics.

#### **Callout: DeFi Llama Integration**

Solar DEX metrics are available on **DeFi Llama**, providing insights into total value locked (TVL), volume, and liquidity. However, for the most accurate and up-to-date data, Solar DEX’s live metrics through the SDK surpass third-party aggregators. Developers can use the SDK to pull reliable, real-time metrics directly from the source.

***

#### **Steps for Using the API**

1. **Obtain API Access**: If required, request an API key from Solar DEX to unlock advanced functionality.
2. **Use API Endpoints**:
   * **Volume Data**:

     ```javascript
     javascriptCopy codeconst volume = await dex.getVolume();
     console.log(`24-hour trading volume: ${volume}`);
     ```
   * **Liquidity Added**:

     ```javascript
     javascriptCopy codeconst liquidity = await dex.getLiquidity('POOL_ID');
     console.log(`Liquidity in pool: ${liquidity}`);
     ```
3. **Integrate Analytics**: Build dashboards or applications that provide live updates on trading activity and liquidity.
4. **Enhance User Experience**: Use API data to offer traders insights into their performance, transaction history, and market opportunities.

***

#### **Why Solar DEX SDK is a Game-Changer**

The Solar DEX SDK empowers developers to unlock the full potential of the Solar DEX ecosystem. By providing real-time data, seamless trading functionality, and robust integration tools, the SDK simplifies the creation of advanced DeFi applications. Its integration with the Eclipse Network ensures scalability, low latency, and cost-effective operations, making it an essential tool for developers in the decentralized space.

###

<br>
