Skip to main content
In this section, you’ll learn how to request ready-to-use transaction data (bytecode) for depositing into a yield position.
Prerequisites: Make sure you’ve reviewed how to check protocol info first.

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 operationlend
amountAmount in token’s smallest unit10000000
walletWallet that will own the position0x1234...
Optional Parameters (same-chain swap):
ParameterDescriptionExample
fromTokenToken address to swap from before depositing (same-chain). When provided, the response includes swap transaction(s) before the deposit bytecode.0xC02aaA39... (WETH)
When fromToken is provided, the API automatically prepends a swap from fromToken to the strategy’s underlying asset on the same chain. The amount parameter refers to the amount of fromToken to swap. The response metadata will have isSameChainSwap: true.
Optional Parameters (cross-chain):
ParameterDescriptionExample
fromChainIdSource chain ID (for cross-chain deposits)1 (Ethereum)
fromTokenAddressSource token address (required if fromChainId)0xA0b86991c... (USDC on ETH)
toTokenAddressDestination token address (for cross-chain)0x2791Bca1f... (USDC on Polygon)
outputResponse format: “bytecode” or “userOperation”bytecode (default)
Example Request (direct deposit):
GET /strategies/aave-usdc-polygon/bytecode?action=lend&amount=10000000&wallet=0x1234...
Example Response:
{
  "feeCharged": "0",
  "metadata": {
    "isCrossChain": false,
    "isSameChainSwap": false,
    "crossChainQuoteId": null
  },
  "bytecode": [
    {
      "to": "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
      "value": "0",
      "data": "0xe8eda9df...",
      "chainId": 137
    }
  ]
}
Example Request (same-chain swap + deposit): If you hold WETH but want to deposit into a USDC strategy, pass fromToken to swap first:
GET /strategies/aave-usdc-polygon/bytecode?action=lend&amount=1000000000000000000&wallet=0x1234...&fromToken=0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619
Example Response:
{
  "feeCharged": "0",
  "metadata": {
    "isCrossChain": false,
    "isSameChainSwap": true,
    "crossChainQuoteId": null
  },
  "bytecode": [
    {
      "to": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
      "value": "0",
      "data": "0x54e3f31b...",
      "chainId": 137
    },
    {
      "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: 'lend', amount: '10000000', wallet: walletAddress }
})

for (const tx of result.bytecode) {
  await signer.sendTransaction({ to: tx.to, value: tx.value, data: tx.data })
}

console.log('Deposit successful!')

Next Steps