In this section, you’ll learn how to request ready-to-use transaction data (bytecode) for withdrawing from a yield position.
Protocol-Specific Approach
Use this when you want to work with a specific yield protocol.
Request Transaction Data
Fetch specific protocol information using:
GET /strategies/:id/bytecode
Required Parameters:
| Parameter | Description | Example |
|---|
| action | Type of operation | withdraw |
| amount | Amount in token’s smallest unit | 10000000 |
| wallet | Wallet that owns the position | 0x1234... |
Optional Parameters (cross-chain):
| Parameter | Description | Example |
|---|
| fromChainId | Source chain ID (for cross-chain withdrawals) | 1 (Ethereum) |
| toTokenAddress | Destination token address (for cross-chain) | 0xA0b86991c... (USDC on ETH) |
| output | Response format: “bytecode” or “userOperation” | bytecode (default) |
Example Request:
GET /strategies/aave-usdc-polygon/bytecode?action=withdraw&amount=10000000&wallet=0x1234...
Example Response:
{
"feeCharged": "0",
"metadata": {
"isCrossChain": false,
"isSameChainSwap": false,
"crossChainQuoteId": null
},
"bytecode": [
{
"to": "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
"value": "0",
"data": "0xe8eda9df...",
"chainId": 137
}
]
}
crossChainQuoteId is populated when isCrossChain is true and can be used to track cross-chain transaction status.
To let the system automatically select the best protocol, use
GET /yield/ to retrieve ranked recommendations, then pass
the chosen strategyId into the Protocol-Specific approach above.
See the API Reference for the full yield endpoint schema.
Executing the Transaction
Once you have the bytecode, you can execute it using your wallet provider:
// Example using ethers.js
const { data: result } = await deframe.get('/strategies/aave-usdc-polygon/bytecode', {
params: { action: 'withdraw', amount: '10000000', wallet: walletAddress }
})
for (const tx of result.bytecode) {
await signer.sendTransaction({ to: tx.to, value: tx.value, data: tx.data })
}
console.log('Withdrawal successful!')
Make sure you have sufficient balance in your position before attempting to withdraw. Check your open positions first using the check positions endpoint.
Next Steps