Skip to main content
POST
/
withdraw
curl -X POST "https://api.strike.markets/withdraw" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "0x742d35cc6C6C7532B1140Da4C8A2f6C8ECfC9B46",
    "amount": "250.0",
    "txHash": "0x1234567890abcdef1234567890abcdef12345678901234567890abcdef123457",
    "timestamp": "2024-01-15T15:45:00Z"
  }'
{
  "success": true,
  "message": "Withdrawal verified and recorded successfully"
}
curl -X POST "https://api.strike.markets/withdraw" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "0x742d35cc6C6C7532B1140Da4C8A2f6C8ECfC9B46",
    "amount": "250.0",
    "txHash": "0x1234567890abcdef1234567890abcdef12345678901234567890abcdef123457",
    "timestamp": "2024-01-15T15:45:00Z"
  }'
{
  "success": true,
  "message": "Withdrawal verified and recorded successfully"
}

Overview

Record and verify a user withdrawal from Strike Protocol. This endpoint validates on-chain withdrawal transactions and updates your account balance accordingly.
This endpoint does NOT require authentication as it verifies transactions on-chain. The transaction hash provides proof of the withdrawal operation.

How Withdrawals Work

Process Flow

  1. Withdrawal Request: Initiated through Strike Protocol frontend or smart contract
  2. On-chain Execution: Withdrawal transaction executed on blockchain
  3. Record Withdrawal: Call this endpoint with transaction details
  4. Verification: API verifies the transaction on-chain
  5. Balance Update: Your Strike Protocol balance is debited

Withdrawal Types

  • Standard Withdrawal: Normal withdrawal of available balance
  • Emergency Withdrawal: Withdrawal of all funds during emergencies
  • Partial Withdrawal: Withdrawal of portion of available balance

Request Body

walletAddress
string
required
Ethereum wallet address that initiated the withdrawal.Format: 42-character hex string starting with “0x”
Example: “0x742d35cc6C6C7532B1140Da4C8A2f6C8ECfC9B46”
amount
string
required
Withdrawal amount in USD.Format: Decimal string
Example: “250.0”
txHash
string
required
Ethereum transaction hash for the withdrawal.Format: 66-character hex string starting with “0x”
Example: “0x1234567890abcdef1234567890abcdef12345678901234567890abcdef123457”
timestamp
string
required
ISO timestamp when the withdrawal transaction was submitted.Format: ISO 8601 with UTC timezone
Example: “2024-01-15T15:45:00Z”

Response Fields

success
boolean
Indicates if the withdrawal was verified and recorded successfully
message
string
Descriptive message about the operation result

Verification Process

On-Chain Validation

The API performs comprehensive verification:
  1. Transaction Existence: Confirms withdrawal transaction exists on-chain
  2. Contract Interaction: Verifies transaction interacted with Strike Protocol contract
  3. Amount Matching: Confirms withdrawn amount matches request
  4. Wallet Verification: Ensures withdrawal was sent to specified wallet
  5. Duplicate Prevention: Prevents double-counting of the same withdrawal
  6. Balance Validation: Ensures sufficient balance existed before withdrawal

Verification Criteria

  • Block Confirmations: Minimum confirmations required for security
  • Contract Address: Must originate from official Strike Protocol contract
  • Asset Type: Must be supported asset (USDC)
  • Transaction Success: Withdrawal must have completed successfully

Withdrawal Mechanics

Balance Updates

After successful verification:
  • Account Balance: Decreased by withdrawal amount
  • Withdrawable Balance: Reduced accordingly
  • Reserved Balance: Remains unchanged (margin for open positions)

Withdrawal Limits

  • Available Balance: Can only withdraw non-reserved funds
  • Open Positions: Must maintain sufficient margin for positions
  • Minimum Balance: May have minimum balance requirements

Processing Time

  • Verification: Usually instant if transaction is confirmed
  • Balance Update: Immediate after verification
  • Blockchain Settlement: Funds available in wallet immediately

Error Responses

400 Bad Request
object
Invalid request parameters or transaction verification failed
{
  "error": 400,
  "message": "Transaction verification failed: withdrawal not from Strike Protocol contract"
}
Common causes:
  • Invalid wallet address format
  • Transaction hash not found
  • Amount doesn’t match on-chain transaction
  • Withdrawal not from Strike Protocol contract
  • Transaction failed or was reverted
409 Conflict
object
Transaction already recorded (duplicate submission)
{
  "error": 409,
  "message": "Withdrawal transaction already recorded"
}
503 Service Unavailable
object
Blockchain RPC issues or temporary verification problems
{
  "error": 503,
  "message": "Unable to verify withdrawal transaction, please try again"
}

Usage Examples

Standard Withdrawal

{
  "walletAddress": "0x742d35cc6C6C7532B1140Da4C8A2f6C8ECfC9B46",
  "amount": "500.0",
  "txHash": "0x...",
  "timestamp": "2024-01-15T15:45:00Z"
}

Partial Withdrawal

{
  "walletAddress": "0x742d35cc6C6C7532B1140Da4C8A2f6C8ECfC9B46",
  "amount": "100.0",
  "txHash": "0x...",
  "timestamp": "2024-01-15T15:45:00Z"
}

Large Withdrawal

{
  "walletAddress": "0x742d35cc6C6C7532B1140Da4C8A2f6C8ECfC9B46",
  "amount": "5000.0",
  "txHash": "0x...",
  "timestamp": "2024-01-15T15:45:00Z"
}

Making a Withdrawal

Step 1: Check Available Balance

Use Account Info to verify your withdrawable balance.

Step 2: Initiate Withdrawal

Call the withdrawal function on Strike Protocol smart contract or use the frontend interface.

Step 3: Get Transaction Hash

After the withdrawal transaction is confirmed, get the transaction hash from your wallet or block explorer.

Step 4: Record Withdrawal

Call this endpoint with the transaction details to update your Strike Protocol balance.

Step 5: Verify Balance

Confirm your balance was updated correctly using Account Info.

Integration Examples

Web3.js Integration

// Initiate withdrawal through contract
const tx = await strikeContract.withdraw(withdrawAmount);
const receipt = await tx.wait();

// Record withdrawal with API
const response = await fetch('https://api.strike.markets/withdraw', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    walletAddress: userAddress,
    amount: withdrawAmount.toString(),
    txHash: receipt.transactionHash,
    timestamp: new Date().toISOString()
  })
});

Frontend Integration

// After successful withdrawal transaction
async function recordWithdrawal(txHash, amount, userAddress) {
  try {
    const response = await fetch('https://api.strike.markets/withdraw', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        walletAddress: userAddress,
        amount: amount,
        txHash: txHash,
        timestamp: new Date().toISOString()
      })
    });
    
    if (response.ok) {
      console.log('Withdrawal recorded successfully');
      // Update UI balance
      await refreshAccountBalance();
    }
  } catch (error) {
    console.error('Failed to record withdrawal:', error);
  }
}

Balance Management

Available vs Reserved

  • Available Balance: Funds available for withdrawal
  • Reserved Balance: Margin locked in open positions
  • Total Balance: Available + Reserved

Withdrawal Constraints

You can only withdraw funds that are:
  • Not reserved as margin for open positions
  • Not pending in other operations
  • Above any minimum balance requirements

Position Impact

Withdrawals do not affect:
  • Open position margins
  • Position sizes or leverage
  • Liquidation prices
  • Unrealized PnL

Best Practices

Transaction Handling

  • Confirm Success: Ensure withdrawal transaction succeeded before recording
  • Wait for Confirmations: Allow sufficient block confirmations
  • Gas Management: Use appropriate gas limits for withdrawal transactions
  • Error Handling: Implement proper error handling for failed withdrawals

Balance Management

  • Check Availability: Always verify available balance before withdrawal
  • Reserve Calculation: Account for margin requirements in open positions
  • Timing: Consider market conditions and position status

Security Considerations

  • Amount Verification: Double-check withdrawal amounts
  • Contract Verification: Ensure interaction with correct contract
  • Wallet Security: Verify withdrawal destination wallet
  • Transaction Monitoring: Monitor withdrawal transactions for completion

Troubleshooting

Common Issues

  1. “Insufficient withdrawable balance”
    • Check available balance vs. reserved margin
    • Close positions to free up margin
    • Verify account balance is sufficient
  2. “Transaction verification failed”
    • Ensure transaction hash is correct
    • Verify transaction succeeded on-chain
    • Check if withdrawal came from Strike Protocol contract
  3. “Withdrawal transaction already recorded”
    • Withdrawal was already processed
    • Check account balance for debit
    • Don’t resubmit the same transaction
  4. “Unable to verify withdrawal transaction”
    • Blockchain RPC may be experiencing issues
    • Wait for more confirmations
    • Retry after a few minutes

Verification Steps

  1. Check Transaction: View transaction on block explorer
  2. Confirm Source: Ensure withdrawal came from Strike Protocol contract
  3. Verify Amount: Confirm withdrawal amount matches request
  4. Check Status: Ensure transaction completed successfully

Next Steps

After recording a withdrawal:
  1. Verify Balance - Check Account Info for updated balance
  2. Monitor Wallet - Confirm funds arrived in your wallet
  3. Review Activity - Track transaction in Dashboard
  4. Plan Trading - Consider impact on available trading balance
Only withdraw funds that are not reserved as margin for open positions. Ensure you maintain sufficient balance for your trading activities.
Always verify your withdrawal was successful by checking both your Strike Protocol balance and your wallet balance after recording the transaction.

Body

application/json
walletAddress
string
required

User's Ethereum wallet address

amount
string
required

Withdrawal amount in USD

txHash
string
required

Transaction hash for verification

timestamp
string<date-time>
required

ISO timestamp

Response

Withdrawal recorded and verified successfully

success
boolean
message
string