Deframe
  • 🏠Getting Started
  • 🏗️Architecture Overview
  • Tutorial Guides
    • Loans
      • How to quote for a new loan
      • How to execute a new loan
      • How to get current position of a loan
      • How to repay a loan
    • Yield
      • How to check protocol info
      • How to deposit
      • How to check open positions
      • How to withdraw
    • Swaps
      • EVM
        • How to execute a swap
        • How to get a quote
      • Solana
        • How to execute a swap
        • How to get a quote
  • ⚙️API
    • GET /strategies
    • GET /strategies/:id
    • GET /strategies/:id/bytecode
    • GET /wallets/:address
  • 🔒Protocols
  • 🗳️Widget Integration
Powered by GitBook
On this page
  1. API

GET /strategies/:id/bytecode

🔹 Get Strategy Bytecode

🌐 Endpoint

GET https://client.deframe.io/v1/strategies/:id/bytecode

📝 Overview

Retrieve ready-to-use transaction data (bytecode) for executing operations like loans, swaps, or yield positions with a specific strategy.

🔑 Authentication

This API requires authentication using an API key. Include your API key in the request headers:

x-api-key: YOUR_API_KEY

📋 Path Parameters

Parameter
Type
Description
Example

id

string

Unique identifier for strategy

Aave-USDT-polygon

📋 Query Parameters

Parameter
Type
Required
Description
Example

action

string

Yes

Type of operation to execute

borrow, repay, deposit, withdraw

chainId

string

Yes

Network chain ID

137 (Polygon)

amount

string

Yes

Amount with decimals

1000000000000000000 (1 ETH)

asset

string

Yes

Asset symbol

ETH, USDC

collateralAsset

string

For loans

Collateral asset symbol (for loans)

ETH

collateralAmount

string

For loans

Collateral amount with decimals (for loans)

900000000000000000000000

slippage

number

For swaps

Maximum price slippage percentage (for swaps)

0.5

deadline

number

For swaps

Transaction deadline in seconds (for swaps)

1800

📦 Response

Returns a JSON object containing:

  • bytecode: Array of transaction objects with the following properties:

    • to: Target contract address

    • value: Amount of native tokens to send (in wei)

    • data: Transaction bytecode

Example Response for Loan:

{
  "bytecode": [
    {
      "to": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
      "value": "0",
      "data": "0xa9059cbb0000000000000000000000005900efdd79bc1541cf1f9fd0f56c0a869194430300000000000000000000000000000000000000000000000000000000000003e8"
    },
    {
      "to": "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
      "value": "0",
      "data": "0x617ba0370000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c335900000000000000000000000000000000000000000000000000000000000f3e58000000000000000000000000d90aa547a8c6b535e8cdce7b67f01b41035d925e0000000000000000000000000000000000000000000000000000000000000000"
    }
  ]
}

Example Response for Swap:

{
  "bytecode": [
    {
      "to": "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
      "value": "1000000000000000000",
      "data": "0xe8eda9df0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000"
    }
  ]
}

❌ Error Responses

Status Code
Description

400

Bad Request - Invalid parameters

401

Unauthorized - Invalid or missing API key

404

Strategy not found

429

Too many requests - Rate limit exceeded

500

Internal server error

Example Error Response:

{
  "error": {
    "code": "INVALID_PARAMETERS",
    "message": "Required parameter 'amount' is missing"
  }
}

📝 Notes

  • The bytecode response may contain one or more transactions that need to be executed in sequence

  • All amounts should include the appropriate number of decimals for the asset

  • For loans, both collateralAsset and collateralAmount are required

  • For swaps, slippage and deadline parameters are recommended to prevent unfavorable executions

PreviousGET /strategies/:idNextGET /wallets/:address

Last updated 3 months ago

⚙️