Skip to main content
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:
ParameterDescriptionExample
actionType of operationwithdraw
amountAmount in token’s smallest unit10000000
walletWallet that owns the position0x1234...
Optional Parameters (cross-chain):
ParameterDescriptionExample
fromChainIdSource chain ID (for cross-chain withdrawals)1 (Ethereum)
toTokenAddressDestination token address (for cross-chain)0xA0b86991c... (USDC on ETH)
Optional Parameters (response format):
ParameterDescriptionExample
outputResponse format: bytecode (default), userOperation, fireblocks, or instructions (Solana)fireblocks
accountIdFireblocks vault account ID. Required when output=fireblocks12
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.
Example Request (Fireblocks output): If you are using Fireblocks custody, set output=fireblocks and pass your vault accountId. The wallet parameter must be a smart wallet previously provisioned via POST /fireblocks-smart-account (see Fireblocks Integration).
GET /strategies/aave-usdc-polygon/bytecode?action=withdraw&amount=10000000&wallet=0xSafeAddress&output=fireblocks&accountId=YOUR_VAULT_ACCOUNT_ID
Example Response:
{
  "feeCharged": "0",
  "metadata": {
    "isCrossChain": false,
    "isSameChainSwap": false,
    "crossChainQuoteId": null
  },
  "transactionData": {
    "transactionRequest": {
      "operation": "CONTRACT_CALL",
      "assetId": "MATIC_POLYGON",
      "source": {
        "type": "VAULT_ACCOUNT",
        "id": "YOUR_VAULT_ACCOUNT_ID"
      },
      "destination": {
        "type": "ONE_TIME_ADDRESS",
        "oneTimeAddress": {
          "address": "0xSafeAddress"
        }
      },
      "amount": "0",
      "extraParameters": {
        "contractCallData": "0x6a761202..."
      },
      "note": "withdraw aave-usdc-polygon",
      "failOnLowFee": true
    }
  }
}
The transactionData.transactionRequest payload can be submitted directly to the Fireblocks Transactions API (POST /v1/transactions) — no further encoding required. The Earn Owner vault must be configured as the signer (see Fireblocks Integration). After the withdrawal completes, transfer funds out of the smart wallet to your Omnibus wallet or any other destination.
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

Check Positions

View your remaining positions

New Deposit

Make a new deposit

Protocol Info

Check protocol information