Skip to main content
A withdraw, or Zap Out, is the reverse of a deposit: DZap exits your position and swaps what comes out into the token you pick, bridging it to another chain if you ask. You find the position with getZapPositions and pass its address as srcToken. Pick EVM or Solana in any tab, and the rest of the page switches with it.

Setup

This example exits a Uniswap position on Base back into USDC, signing with walletClient, a viem wallet client built from the private key in PRIVATE_KEY. No API key is needed.
getZapChains lists the provider IDs each chain supports.

Steps

1

Find the position

getZapPositions lists your open positions with one provider on one chain. Each has its address, amount and value in amountUSD. Uniswap positions are NFTs, so they also carry nftDetails: the NFT’s id and its manager contract.
2

Quote

getZapQuote returns the exit route and what you’ll get back. srcToken is the position’s address and positionDetails.nftId names the NFT; with no amount, the whole position exits. For a partial exit, set amount to part of position.amount. destToken doesn’t have to be USDC: other tokens and native ETH work when DZap has a route, and setting destChainId to another chain bridges the result there.
3

Approve

The zap contract, the quote’s approvalData[0].approveTo, needs permission to move the position NFT. approve() handles NFTs too: pass the NFT’s manager as the token and its id as the amount.
Exiting an ERC-20 position, such as a vault share or a Curve LP token? Leave out positionDetails, set amount, and approve the token with getAllowance and approve() as on the deposit page.
4

Build & send

buildZapTxn builds the exit and checks it against your wallet, so it throws if it would fail. zap() then signs and sends it: one transaction exits the position and swaps what comes out into USDC for recipient.
5

Status

Poll getZapTxnStatus with the transaction hash until the status leaves PENDING; COMPLETED means every step finished, and status.steps reports each one. DZap answers 404 until it sees the transaction, and 429 once its rate limit is used up, so the catch skips only those two and rethrows anything else. The loop gives up after 5 minutes (raise it if the route bridges), and the check after it throws unless the status is COMPLETED.

End-to-end

API usage

The same flow over REST, on the zap API at https://zap.dzap.io/v1. Each response wraps its result in data.
Approve the position NFT for the quote’s approvalData[0].approveTo and wait for it to confirm before building, since the build checks it. Then send the build’s steps[0].data (callTo, callData, value) from your wallet. Full reference: Positions, Quote, Build Tx, Status.

What can go wrong

  • NFT id not found: the position is an NFT and the request has no positionDetails.nftId.
  • Amount not found or Token amount not found: the position is a token and the request has no amount.
  • No valid quote found: DZap has no route from the position to that destToken. Pick another token.
  • buildZapTxn throws Execution reverted: the build checks the exit against your wallet, so the position’s approval must be confirmed first. The error response’s message has the revert reason.
  • positions is empty: the wallet has no open position with that provider on that chain. getZapChains lists the provider IDs each chain supports.
  • currently withdrawable from this market: the lending market doesn’t have that much free liquidity right now. Exit part of the position now and the rest later.
  • Several Solana transactions: some Solana routes return two or more transactions with isJitoTx: true, which have to land together as a Jito bundle. The SDK can’t submit bundles yet, so the code here covers single-transaction routes like Jupiter Lend.
  • Blockhash not found or ComputationalBudgetExceeded on Solana: the transaction expired before you sent it, or needed more compute than the build allowed. Build and sign again right away.
  • Not completed: no status: DZap never returned a status, usually because the transaction failed on-chain. On Solana, query by the signature; the build’s txnId returns Failed to process transaction.
  • HTTP 429: the zap API allows 60 requests a minute.
See Error codes for the full catalog.
Last modified on October 1, 2026