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

# Deposit Generation

> Generate unsigned transactions for executing swaps across different blockchain ecosystems

## POST /leokit/deposit

Generate unsigned transaction(s) for executing a swap based on a previously obtained quote.

### Request Body

```json theme={null}
{
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "selected_protocol": "thorchain"
}
```

| Field               | Type   | Required | Description                           |
| ------------------- | ------ | -------- | ------------------------------------- |
| `quote_id`          | string | Yes      | UUID from quote response              |
| `selected_protocol` | string | Yes      | Protocol to use (must exist in quote) |

### Validation Rules

1. **Quote Existence** - Quote must exist in database
2. **Client Ownership** - Quote must belong to requesting client (API key match)
3. **Protocol Availability** - Selected protocol must be in quote's available protocols
4. **Quote Expiry** - Quote must not be expired (protocol-specific rules)
5. **Ecosystem Support** - Blockchain ecosystem must be supported

## Response Formats by Ecosystem

The response format varies based on the source blockchain ecosystem.

## UTXO Chains (Bitcoin, Litecoin, Dogecoin, Dash)

**Supported Chains:** BTC, LTC, DOGE, DASH

### PSBT Format (BTC, LTC, DOGE)

```json theme={null}
{
  "type": "UTXO",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "to_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    "from_asset": "BTC.BTC",
    "to_asset": "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "amount": "100000000",
    "decimals": 8,
    "memo": "=:ETH.USDC-0xA0b86991:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb:198500000"
  },
  "unsigned_transaction": {
    "psbt_hex": "cHNidP8BAH0CAAAAAR...",
    "selected_utxos": [
      {
        "txid": "a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890",
        "vout": 0,
        "value": 105000000,
        "script": "0014751e76e8199196d454941c45d1b3a323f1433bd6"
      }
    ],
    "chain": "BTC"
  }
}
```

### Raw Transaction Format (DASH)

For DASH, `raw_unsigned_tx` is provided instead of `psbt_hex`:

```json theme={null}
{
  "type": "UTXO",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "Xy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "to_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    "from_asset": "DASH.DASH",
    "to_asset": "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "amount": "100000000",
    "decimals": 8,
    "memo": "=:ETH.USDC-0xA0b86991:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb:198500000"
  },
  "unsigned_transaction": {
    "raw_unsigned_tx": "0200000001a1b2c3d4...",
    "selected_utxos": [
      {
        "txid": "a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890",
        "vout": 0,
        "value": 105000000,
        "script": "76a914751e76e8199196d454941c45d1b3a323f1433bd688ac"
      }
    ],
    "chain": "DASH"
  }
}
```

### Key Features

* **PSBT Format:** Bitcoin, Litecoin, Dogecoin use Partially Signed Bitcoin Transaction format
* **OP\_RETURN Memo:** Embedded in transaction for THORChain/MAYA swaps
* **UTXO Selection:** Automatic selection with fee estimation
* **Change Outputs:** Only created if above dust threshold (546 sats for BTC/LTC, 1 DOGE for DOGE)

### Memo Length Limits

* **BTC/LTC:** 150 bytes (OP\_RETURN limit: 80 bytes)
* **DOGE:** 80 bytes

## EVM Chains (Ethereum, BSC, Arbitrum, etc.)

**Supported Chains:** ETH, BSC, ARB, AVAX, BASE, POLYGON, OPTIMISM, FANTOM

### Native Token Transfer (ETH, BNB, etc.)

```json theme={null}
{
  "type": "EVM",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    "to_address": "0x1234567890AbcdEF1234567890aBcdef12345678",
    "from_asset": "ETH.ETH",
    "to_asset": "BTC.BTC",
    "amount": "1000000000000000000",
    "decimals": 18,
    "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh:9850000000"
  },
  "unsigned_transactions": [
    {
      "from": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
      "to": "0xD37BbE5744D730a1d98d8DC97c42F0Ca46aD7146",
      "value": "0xde0b6b3a7640000",
      "data": "0x44bc937b0000000000000000000000001234567890abcdef1234567890abcdef12345678...",
      "nonce": 42,
      "chainId": 1,
      "gasLimit": "150000",
      "maxFeePerGas": "50000000000",
      "maxPriorityFeePerGas": "2000000000"
    }
  ]
}
```

### ERC20 Token Transfer with Approval

```json theme={null}
{
  "type": "EVM",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    "to_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "from_asset": "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "to_asset": "BTC.BTC",
    "amount": "2000000000",
    "decimals": 6,
    "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
  },
  "unsigned_transactions": [
    {
      "from": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
      "to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "value": "0x0",
      "data": "0x095ea7b3000000000000000000000000d37bbe5744d730a1d98d8dc97c42f0ca46ad714600000000000000000000000000000000000000000000000000000000773594000",
      "nonce": 42,
      "chainId": 1,
      "gasLimit": "60000",
      "maxFeePerGas": "50000000000",
      "maxPriorityFeePerGas": "2000000000"
    },
    {
      "from": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
      "to": "0xD37BbE5744D730a1d98d8DC97c42F0Ca46aD7146",
      "value": "0x0",
      "data": "0x44bc937b...",
      "nonce": 43,
      "chainId": 1,
      "gasLimit": "180000",
      "maxFeePerGas": "50000000000",
      "maxPriorityFeePerGas": "2000000000"
    }
  ]
}
```

### Key Features

* **Multiple Transactions:** ERC20 swaps require approval + deposit transactions
* **USDT Special Case:** Allowance reset to 0 before setting new amount
* **Nonce Sequencing:** Sequential nonce for each transaction in array
* **EIP-1559:** Supports both legacy (gasPrice) and EIP-1559 (maxFeePerGas) formats
* **Router Contracts:** THORChain/MAYA use depositWithExpiry function
* **Direct Transfers:** Chainflip and NEAR use simple transfers to deposit addresses

### QR Code Enrichment (Chainflip & NEAR)

When the selected protocol is `chainflip` or `near`, the deposit response is automatically enriched with a `deposit_address`, `payment_uri`, and `qr_url`. These allow users to complete swaps by scanning a QR code from any wallet app.

```json theme={null}
{
  "type": "EVM",
  "protocol": "chainflip",
  "quote_id": "01936b4a-...",
  "details": { ... },
  "unsigned_transactions": [ ... ],
  "deposit_address": "0x8a3c1f...",
  "payment_uri": "ethereum:0x8a3c1f...@1?value=500000000000000000",
  "qr_url": "https://cdn.leokit.dev/qr/01936b4a-....png"
}
```

| Field             | Type   | Description                                                    |
| ----------------- | ------ | -------------------------------------------------------------- |
| `deposit_address` | string | The generated deposit address (Chainflip channel or NEAR)      |
| `payment_uri`     | string | Chain-specific payment URI (BIP-21, EIP-681, Solana Pay, etc.) |
| `qr_url`          | string | CDN URL of a QR code PNG encoding the `payment_uri`            |

<Note>
  These fields are only present for `chainflip` and `near` protocols. Other protocols (thorchain, relay, etc.) do not include them.
</Note>

## NEAR Protocol

### Native NEAR Transfer

```json theme={null}
{
  "type": "NEAR",
  "protocol": "near",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "alice.near",
    "to_address": "bob.near",
    "from_asset": "NEAR.NEAR",
    "to_asset": "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "amount": "5000000000000000000000000",
    "decimals": 24
  },
  "unsigned_transaction": {
    "receiverId": "swap.1click.near",
    "actions": [
      {
        "type": "Transfer",
        "params": {
          "deposit": "5000000000000000000000000"
        }
      }
    ]
  }
}
```

### NEP-141 Token Transfer

```json theme={null}
{
  "type": "NEAR",
  "protocol": "near",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "alice.near",
    "to_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    "from_asset": "NEAR.USDC-a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near",
    "to_asset": "ETH.ETH",
    "amount": "2000000000",
    "decimals": 6
  },
  "unsigned_transaction": {
    "receiverId": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near",
    "actions": [
      {
        "type": "FunctionCall",
        "params": {
          "methodName": "ft_transfer",
          "args": {
            "receiver_id": "swap.1click.near",
            "amount": "2000000000",
            "memo": null
          },
          "gas": "30000000000000",
          "deposit": "1"
        }
      }
    ]
  }
}
```

### Key Features

* **YoctoNEAR:** All amounts in yoctoNEAR (10^24 for native NEAR)
* **Fixed Gas:** 30 TGas for ft\_transfer calls
* **Attached Deposit:** 1 yoctoNEAR required for token transfers
* **Contract Parsing:** Extracts contract address from asset format

## Cosmos Chains

**Supported Chains:** Cosmos Hub, Kujira, THORChain (native RUNE)

### MsgSend (Standard Cosmos Transfer)

```json theme={null}
{
  "type": "COSMOS",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "cosmos1xyz...",
    "to_address": "thor1abc...",
    "from_asset": "GAIA.ATOM",
    "to_asset": "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "amount": "1000000",
    "decimals": 6,
    "memo": "=:ETH.USDC:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
  },
  "unsigned_transaction": {
    "msgs": [
      {
        "typeUrl": "/cosmos.bank.v1beta1.MsgSend",
        "value": {
          "fromAddress": "cosmos1xyz...",
          "toAddress": "cosmos1depositaddress...",
          "amount": [
            {
              "denom": "uatom",
              "amount": "1000000"
            }
          ]
        }
      }
    ],
    "fee": {
      "gas": "200000",
      "amount": [
        {
          "denom": "uatom",
          "amount": "5000"
        }
      ]
    },
    "memo": "=:ETH.USDC:0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    "chainId": "cosmoshub-4",
    "accountNumber": 12345,
    "sequence": 67
  }
}
```

### MsgDeposit (THOR.RUNE Native Swaps)

```json theme={null}
{
  "type": "COSMOS",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "thor1abc...",
    "to_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "from_asset": "THOR.RUNE",
    "to_asset": "BTC.BTC",
    "amount": "100000000",
    "decimals": 8,
    "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
  },
  "unsigned_transaction": {
    "msgs": [
      {
        "typeUrl": "/types.MsgDeposit",
        "value": {
          "coins": [
            {
              "asset": "THOR.RUNE",
              "amount": "100000000"
            }
          ],
          "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
          "signer": "thor1abc..."
        }
      }
    ],
    "fee": {
      "gas": "250000",
      "amount": [
        {
          "denom": "rune",
          "amount": "2000000"
        }
      ]
    },
    "chainId": "thorchain-mainnet-v1",
    "accountNumber": 12345,
    "sequence": 67
  }
}
```

### Key Features

* **Gas Simulation:** Real-time estimation with 30% buffer
* **Dynamic Fees:** Based on recommended\_gas\_rate from inbound\_addresses API
* **Account Lookup:** Fetches sequence and account number automatically
* **Fixed RUNE Fee:** 0.02 RUNE for THORChain transactions

## Other Ecosystems

### TRON

```json theme={null}
{
  "type": "TRON",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "TXyz123...",
    "to_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "from_asset": "TRON.TRX",
    "to_asset": "BTC.BTC",
    "amount": "1000000",
    "decimals": 6,
    "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
  },
  "unsigned_transaction": {
    "raw_data": {...},
    "raw_data_hex": "0a02...",
    "txID": "abc123..."
  }
}
```

### Cardano

```json theme={null}
{
  "type": "CARDANO",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "addr1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh...",
    "to_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "from_asset": "CARDANO.ADA",
    "to_asset": "BTC.BTC",
    "amount": "1000000",
    "decimals": 6,
    "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
  },
  "unsigned_transaction": {
    "cbor_hex": "84a40081..."
  }
}
```

### XRP

```json theme={null}
{
  "type": "XRP",
  "protocol": "thorchain",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890",
  "details": {
    "from_address": "rXyz123...",
    "to_address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
    "from_asset": "XRP.XRP",
    "to_asset": "BTC.BTC",
    "amount": "1000000",
    "decimals": 6,
    "memo": "=:BTC.BTC:bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
  },
  "unsigned_transaction": {
    "tx_blob": "120000228000000024...",
    "hash": "ABC123..."
  }
}
```
