> ## Documentation Index
> Fetch the complete documentation index at: https://developer.fin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ByBit

The ByBit integration allows a developer to enable a ByBit user to use their [ByBit Pay](https://www.bybit.com/en/bybitpay/) balance to deposit in their desired platform / wallet address.

<Tip>
  Check the use cases that it can serve [here](https://developer.fin.com/crypto-orchestration).
</Tip>

The supported sources and destinations can be found below along with important integration information.

<Card title="Go over legends & concepts ✅" icon="external-link" href="https://developer.fin.com/legends-and-concepts">
  Learn key terminologies for a better implementation
</Card>

| **Supported Source Currency** | **Supported Source Rail** | **Supported Destination Currency** | **Supported Destination Rail** | **Quote Estimation** | **Minimum Order Limit** | **Maximum Order Limit** | **Estimated Settlement Time (once deposit received)** | **Settlement Configuration (**`settlment_via`**)** | Fee rebalancing capability (`rebalance_fee`)           |
| :---------------------------- | :------------------------ | :--------------------------------- | :----------------------------- | :------------------- | :---------------------- | :---------------------- | :---------------------------------------------------- | :------------------------------------------------- | ------------------------------------------------------ |
| USDC                          | BYBIT                     | USDC                               | SOLANA                         | ✅                    | 3                       | Not applicable yet      | \~ 3 mins                                             | `ONE_TO_ONE`                                       | `true` / `false`                                       |
| USDC                          | BYBIT                     | USDC                               | ETHEREUM                       | 👷 *In Progress..*   | 7                       | Not applicable yet      | \~ 3 mins                                             | `ONE_TO_ONE`                                       | `true` / `false`                                       |
| USDC                          | BYBIT                     | USDC                               | BASE                           | 👷 *In Progress..*   | 3                       | Not applicable yet      | \~ 3 mins                                             | `ONE_TO_ONE`                                       | `true` / `false`                                       |
| USDT                          | BYBIT                     | PYUSD                              | SOLANA                         | 👷 *In Progress..*   | 3                       | Not applicable yet      | \~ 3 mins                                             | `MARKET_ORDER`                                     | Has to be always `true`  (in roadmap for full support) |

<Note>
  For routes where "Fee rebalancing capability" & "Quote estimation" is limited. Fin can enable both upon request of the Developer or Fin will enable themselves if it is in the roadmap.

  Please send request in your dedicated communication group.
</Note>

## ByBit Quote creation:

The quote endpoint requires a few key action for different settlement configuration at the moment

<Tabs>
  <Tab title="MARKET_ORDER">
    ```json highlight={11} focus={11} theme={null}
    curl --request POST \
      --url https://sandbox.api.fin.com/v1/transit/quote \
      --header 'Authorization: Bearer <token>' \
      --header 'Content-Type: application/json' \
      --data '
    {
      "order_amount": "100.00",
      "integration_type": "BYBIT",
      "settlement_config": {
        "settlement_via": "MARKET_ORDER",
        "rebalance_fee": true,
        "destination_details": {
          "wallet_address": "SOLANA_WALLET_ADDRESS",
          "currency": "USDC",
          "rail": "SOLANA"
        }
      }
    }
    '
    ```
  </Tab>
</Tabs>

<Warning>
  To get a quote using `settlement_via ` = `MARKET_ORDER` , `rebalance_fee` has to be `true` . We are in the processing of adding support for `false` as well.
</Warning>

## ByBit Order creation:

The only required fields in different cases has been share below, more cases to be added as there are more use cases within ByBit that Fin supports.

<Tabs>
  <Tab title="Without Quote ID">
    ```json theme={null}
    curl --request POST \
      --url https://sandbox.api.fin.com/v1/transit/payment \
      --header 'Authorization: Bearer <token>' \
      --header 'Content-Type: application/json' \
      --data '
    {
      "integration_type": "BYBIT",
      "order_info": {
        "payment_type": "E_COMMERCE",
        "merchant_trade_no": "841e4ba2-1234-5678-9abc-a2a45de7bd00",
        "order_amount": "100.00",
        "currency": "USDT",
        "currency_type": "crypto",
        "order_expire_time": 3600,
        "goods": [
          {
            "shopping_name": "test good1",
            "mcc_code": "1520",
            "goods_name": "test1",
            "goods_detail": "First product"
          }
        ],
        "env": {
          "terminal_type": "APP",
          "device": "iPhone 15",
          "browser_version": "iOS 17.0 Safari",
          "ip": "192.168.0.1"
        },
      },
      "fin": {
        "settlement_config": {
          "settlement_via": "MARKET_ORDER",
          "destination_details": {
            "wallet_address": "Ox....",
            "currency": "PYUSD",
            "rail": "SOLANA"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="With Quote ID">
    ```json theme={null}
    curl --request POST \
      --url https://sandbox.api.fin.com/v1/transit/payment \
      --header 'Authorization: Bearer <token>' \
      --header 'Content-Type: application/json' \
      --data '
    {
      "integration_type": "BYBIT",
      "order_info": {
        "quote_id": "4081fa09-7761-42b6-8f66-24beae1a2ca5",
        "payment_type": "E_COMMERCE",
        "merchant_trade_no": "841e4ba2-1234-5678-9abc-a2a45de7bd00",
        "currency_type": "crypto",
        "goods": [
          {
            "shopping_name": "test good1",
            "mcc_code": "1520",
            "goods_name": "test1",
            "goods_detail": "First product"
          }
        ],
        "env": {
          "terminal_type": "APP",
          "device": "iPhone 15",
          "browser_version": "iOS 17.0 Safari",
          "ip": "192.168.0.1"
        },
      }
    }
    ```
  </Tab>
</Tabs>

<Warning>
  If `quote_id` is provided then `order_amount` & `fin` object **cannot be provided**. Hence if the `quote_id` is not provided then `order_amount` & `fin` object is **mandatory.**
</Warning>

## Definitions of parameters:

Parameters are ByBit specific, hence please find the definitions of those parameters in the APIs below in the table below.

| Param name            | Definition                                                                                                                                      |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `merchant_trade_no`   | UUID from the developer side for a particular order                                                                                             |
| `order_expire_time`   | (Optional) By default the order will be valid for 1 hour. A developer can put their custom time range. The minimum order expire time is 10 mins |
| `goods`               | In ByBit when something is being paid for it is attributed to a good. We need the goods information within this object                          |
| `goods.mcc`           | Universal Merchant Category Codes, can be found [here](https://www.iso.org/standard/79450.html)                                                 |
| `goods.goods_name`    | Name of the good that is being paid for                                                                                                         |
| `goods.goods_detail`  | Detail of the good that is being paid for                                                                                                       |
| `env`                 | **<u>Needs to be accurate</u>**. Details about the customers environment, this requires information regarding the users device information      |
| `env.terminal_type`   | `APP / WEB / WAP / MINIAPP` - where is the customer initiating the payment from                                                                 |
| `env.device`          | Device name of the customer                                                                                                                     |
| `env.browser_version` | Browser version of the customer where the web view is being loaded                                                                              |
| `env.ip`              | Customers IP                                                                                                                                    |

## Response Differences for ByBit

| Integration Type | Response Field           |
| :--------------- | :----------------------- |
| BYBIT            | `data.provider_response` |
