Skip to main content

Overview

Creates an unsigned transaction for depositing liquidity into a Meteora DAMM v2 (Dynamic AMM) pool. The API validates the deposit amounts, builds a combined transaction that transfers tokens from the manager wallet to the LP owner and adds liquidity to the pool, and returns the transaction ready for manager wallet signing.
Manager-only operation: This endpoint requires the manager wallet to sign and submit the transaction. The manager wallet must be configured via the MANAGER_WALLET environment variable.
curl -X POST https://api.zcombinator.io/damm/deposit/build \
  -H "Content-Type: application/json" \
  -d '{
    "tokenAAmount": 1000,
    "tokenBAmount": 0.5
  }'

Request Parameters

tokenAAmount
number
required
Amount of Token A to deposit (in UI units, e.g., 1000 for 1000 USDC). Must be non-negative.
tokenBAmount
number
required
Amount of Token B to deposit (in UI units, e.g., 0.5 for 0.5 SOL). Must be non-negative.
UI units: Amounts are specified in human-readable units (e.g., 1.5 SOL, not 1500000000 lamports). The API automatically converts to raw token amounts based on token decimals.

Response

success
boolean
Indicates if the operation was successful
transaction
string
Base58 encoded unsigned transaction that needs to be signed by the manager wallet
requestId
string
Unique identifier for this deposit request (needed for confirmation)
poolAddress
string
Address of the Meteora DAMM v2 pool
tokenAMint
string
Mint address of Token A in the pool
tokenBMint
string
Mint address of Token B in the pool
isTokenBNativeSOL
boolean
Whether Token B is native SOL (handled specially in transfers)
instructionsCount
number
Number of instructions in the transaction
amounts
object
Object containing deposit amounts (in raw token units):
  • tokenA (string): Token A amount in raw units
  • tokenB (string): Token B amount in raw units
  • liquidityDelta (string): Liquidity amount to be added
message
string
Instructions for the next step in the process

Success Response

{
  "success": true,
  "transaction": "4MzR7dxJNJRVP1Q6k7Y3j8X...",
  "requestId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "poolAddress": "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C",
  "tokenAMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "tokenBMint": "So11111111111111111111111111111111111111112",
  "isTokenBNativeSOL": true,
  "instructionsCount": 9,
  "amounts": {
    "tokenA": "1000000000",
    "tokenB": "500000000",
    "liquidityDelta": "707106781"
  },
  "message": "Sign this transaction with the manager wallet and submit to /damm/deposit/confirm"
}

Error Responses

{
  "error": "Missing required fields: tokenAAmount and tokenBAmount"
}
{
  "error": "tokenAAmount and tokenBAmount must be numbers"
}
Both amounts must be valid numbers, not strings or other types.
{
  "error": "Token amounts must be non-negative"
}
Deposit amounts cannot be negative.
{
  "error": "No positions found for the LP owner. Create a position first."
}
The protocol wallet does not have any LP positions in the configured pool. A position must be created before depositing.
{
  "error": "Deposit amount too small"
}
The calculated liquidity delta is too small to process (rounds to zero).
{
  "error": "Server configuration incomplete. Missing required environment variables."
}
The server is not properly configured to process deposit requests.
{
  "error": "Failed to create deposit transaction"
}

Process Flow

This endpoint performs several steps to build the deposit transaction:
1

Validate Parameters

Ensures tokenAAmount and tokenBAmount are provided, are valid numbers, and are non-negative
2

Validate Server Configuration

Checks that the server is properly configured to process deposit requests
3

Verify Authorization

Validates that the manager wallet is authorized to deposit funds
4

Fetch Pool State

Retrieves the current state of the Meteora DAMM v2 pool
5

Convert to Raw Amounts

Converts UI amounts to raw token amounts based on token decimals (e.g., 1.5 SOL → 1500000000 lamports)
6

Get User Positions

Fetches all LP positions owned by the protocol wallet (uses first position)
7

Calculate Liquidity Amount

Calculates the liquidity amount based on token amounts and current pool state
8

Build Transaction

Creates a transaction that:
  • Transfers tokens from manager wallet
  • Adds liquidity to the pool position
  • Creates any needed token accounts
9

Handle Native SOL

If Token B is native SOL, uses SystemProgram.transfer instead of SPL token transfer
10

Generate Security Hash

Creates a security hash for tamper detection during confirmation
11

Generate Request ID

Creates a unique request ID for tracking this deposit request
12

Return Unsigned Transaction

Returns the Base58 encoded transaction for manager wallet signing

Liquidity Calculation

The liquidity amount is calculated based on:
  • Current pool price
  • Pool price range
  • Token amounts being deposited
  • Token metadata (decimals, transfer fees, etc.)
The calculation ensures optimal liquidity provision based on the current pool state.
First position only: This endpoint deposits to the first position in the pool. If multiple positions exist, deposits go to the first position.

Native SOL Handling

Special handling for wrapped SOL (wSOL):When Token B is the native SOL mint (So11111111111111111111111111111111111111112):
  1. The manager wallet transfers native SOL to the LP owner
  2. Meteora automatically wraps SOL during the add liquidity operation
  3. No intermediate token account is needed for Token B
  4. The deposit flow uses SystemProgram.transfer for the initial transfer

Request ID

The response includes a requestId:
  • Format: Random 16-byte hex string for identifying the request
  • Validity: Must be used within 10 minutes
  • Required: Must be provided to /damm/deposit/confirm
  • One-time use: Cannot be reused after confirmation

Rate Limiting

This endpoint is subject to rate limiting:
  • 10 requests per 5-minute window per IP
  • Returns HTTP 429 when limit exceeded with message: “Too many liquidity requests, please wait a moment.”

Security Considerations

Manager authorization required:
  • Only the configured manager wallet can sign and confirm deposits
  • Tokens are transferred from manager wallet to LP owner, then added to pool
  • LP owner’s signature is added automatically by the API
  • Transaction hash validation prevents tampering during confirmation
  • This ensures only authorized deposits to the pool

Next Steps

After receiving the unsigned transaction:
  1. Deserialize the transaction using @solana/web3.js
  2. Sign the transaction with your manager wallet
  3. Submit the signed transaction to /damm/deposit/confirm
Important: Do not modify the transaction after signing. The confirmation endpoint validates the transaction hash to detect any tampering.

Request Expiration

Deposit requests expire after a period of time:
  • Validity: You must call /damm/deposit/confirm within 10 minutes
  • After expiration: You’ll need to create a new deposit request

Token Balance Requirements

Manager wallet must have sufficient balance:
  • Token A balance >= tokenAAmount (in UI units)
  • Token B balance >= tokenBAmount (in UI units)
  • SOL balance for transaction fees
If balances are insufficient, the transaction will fail during submission.