# Solana Deposit

Deposit BTC to receive BTC.b on Solana.

***

### Overview

The BTC Deposit action converts native Bitcoin to BTC.b (wrapped Bitcoin) on Solana. The flow is similar to depositing to an EVM chain, but uses Solana wallet signing for address confirmation instead of EIP-712 fee authorization.

**Flow:** BTC (Bitcoin) -> BTC.b (Solana)

***

### Basic Usage

```typescript
import { createLombardSDK, Chain, AssetId, Env } from '@lombard.finance/sdk';

const sdk = await createLombardSDK({
  env: Env.stage,
  partner: { partnerId: 'test' },
  providers: {
    solana: () => window.solana,
  },
});

const deposit = sdk.chain.btc.deposit({
  destChain: Chain.SOLANA_DEVNET,
  assetOut: AssetId.BTCb,
  sourceChain: Chain.BITCOIN_SIGNET,
});

await deposit.prepare({
  amount: '0.01',
  recipient: 'SoLaNaWaLLeTaDdReSs1234567890abcdef12345678',
});

const depositAddress = await deposit.generateDepositAddress();
// depositAddress: 'bc1q...'
```

Send BTC to the returned deposit address. BTC.b will be minted to the Solana recipient address after confirmation.

***

### Parameters

#### Deposit Options

| Parameter   | Type    | Required | Description                                       |
| ----------- | ------- | -------- | ------------------------------------------------- |
| destChain   | Chain   | Yes      | Solana destination chain                          |
| assetOut    | AssetId | Yes      | Output asset (AssetId.BTCb)                       |
| sourceChain | Chain   | No       | Bitcoin network (defaults to signet on stage/dev) |

#### Prepare Parameters

| Parameter    | Type   | Required | Description                    |
| ------------ | ------ | -------- | ------------------------------ |
| amount       | string | Yes      | Amount in BTC                  |
| recipient    | string | Yes      | Solana wallet address (base58) |
| referralCode | string | No       | Referral code for attribution  |

***

### Supported Routes

| Source Chain    | Destination Chain | Environment | Asset Out |
| --------------- | ----------------- | ----------- | --------- |
| BITCOIN\_SIGNET | SOLANA\_DEVNET    | stage, dev  | BTC.b     |

***

### How It Differs from EVM Deposits

Solana deposits differ from EVM deposits in two ways:

1. **No fee authorization step.** EVM deposits to Ethereum mainnet require an EIP-712 fee authorization signature. Solana deposits use a Solana wallet signature for address confirmation, which is handled automatically when `generateDepositAddress()` is called.
2. **Recipient address format.** The recipient must be a valid Solana public key (base58-encoded, 32 bytes). EVM deposits accept hex addresses.

***

### Claiming BTC.b

After the Bitcoin transaction is confirmed, BTC.b must be claimed on Solana. This step is handled at the lower level using the `@lombard.finance/sdk-solana` package:

```typescript
import { claimToken } from '@lombard.finance/sdk-solana';

const txHash = await claimToken(provider, {
  recipientAddress: 'SoLaNaWaLLeTaDdReSs...',
  tokenMint: 'BTCBmint...',
  network: 'devnet',
  env: 'stage',
  rawPayload: '0xce25e7c2...',
  proofSignature: '0x...',
});
```

The `rawPayload` and `proofSignature` are provided by the Lombard backend after the Bitcoin deposit is confirmed. The claim function handles the full on-chain flow: consortium validation, payload verification, and BTC.b minting.

> **Important:** The payload selector (`0xce25e7c2`) determines the claim type. BTC.b deposits use the direct mint path via the Asset Router program.

***

### Status Flow

```
IDLE -> NEEDS_ADDRESS_CONFIRMATION -> READY -> ADDRESS_READY
```

The `NEEDS_FEE_AUTHORIZATION` status does not apply to Solana deposits. Address confirmation is handled automatically when calling `generateDepositAddress()`.

***

### With Referral Code

```typescript
await deposit.prepare({
  amount: '0.01',
  recipient: 'SoLaNaWaLLeTaDdReSs1234567890abcdef12345678',
  referralCode: 'PARTNER123',
});
```

***

### Error Handling

Common errors for Solana deposits:

| Error               | Cause                                                   |
| ------------------- | ------------------------------------------------------- |
| `INVALID_CHAIN`     | Destination chain is not a supported Solana chain       |
| `INVALID_ASSET`     | Asset is not BTC.b (Solana deposits only produce BTC.b) |
| `ROUTE_NOT_FOUND`   | Route not available for the current environment         |
| `INVALID_PARAMETER` | Recipient is not a valid Solana address                 |

***

### Provider Setup

The Solana provider must be registered when creating the SDK instance.

```typescript
import { createLombardSDK, Env } from '@lombard.finance/sdk';

const sdk = await createLombardSDK({
  env: Env.stage,
  providers: {
    solana: () => window.solana,
  },
});
```
