getZapBundleQuote / buildZapBundleTx), because a borrow is an action you chain with others rather than a single srcToken → destToken hop. They also need one thing the other zaps don’t: a signature from you, made before the transaction is built. The steps below show where it fits. Pre-execution steps explains why it’s needed and what to watch for, and it’s worth reading before you ship.
Borrowing is EVM-only for now.
Setup
Both examples use Aave v3 on Base, signing withwalletClient, a viem wallet client built from the private key in PRIVATE_KEY. Amounts are strings in the token’s smallest unit, and no API key is needed.
The collateral is named by its position token, the aToken here, not by the underlying asset. Find it with
getZapPools, and your current positions with getZapPositions.Steps
- From a position
- Deposit & borrow
1
Quote
A single
borrow action. srcToken is the collateral position you already hold, with no amount, because nothing moves out of it: the aWETH stays where it is and backs the loan. destToken is what you want to borrow, and destAmount how much. Leave destAmount out and DZap borrows the most your collateral allows.2
Sign the delegation
No token approval here, since your collateral never leaves Aave. The only thing to authorize is the borrow itself: sign the credit delegation the quote asked for (see Pre-execution steps).
prepareZapPreExecutionData doesn’t throw. Like approve() and zap(), it hands back a status, so if the user rejects the signature you get rejected and an errorMsg to show.3
Build & send
Add the signatures to the request and build.
buildZapBundleTx checks the borrow against your Aave account, so it throws if you’re asking for more than your collateral covers. zap() then sends the transaction, and the USDC lands at recipient.4
Status
Poll
getZapTxnStatus with the transaction hash until it leaves PENDING. DZap answers 404 until it has seen the transaction and 429 when you hit the rate limit, so the catch lets only those two through. It gives up after 5 minutes.End-to-end
- From a position
- Deposit & borrow
API usage
The same flow over REST, on the bundle endpoints athttps://zap.dzap.io/v1/bundle. Each response wraps its result in data.
- From a position
- Deposit & borrow
data.preExecutionSteps and send the results as preExecutionStepsData. Pre-execution steps shows how to do that without the SDK. Then send the build’s steps[0].data (callTo, callData, value) from your wallet. Full reference: Bundle, Status.