Skip to main content
POST
/
v2
/
earn
/
bundle
Python (SDK)
from compass_api_sdk import CompassAPI, models


with CompassAPI(
    api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:

    res = compass_api.earn.earn_bundle(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.Chain.ETHEREUM, actions=[
        {
            "body": {
                "action_type": "V2_TRANSFER_FROM_EOA",
                "token": "USDC",
                "amount": "100",
                "permit2_signature": "0x...",
                "permit2_nonce": 1706000000,
                "permit2_deadline": 1706001800,
            },
        },
        {
            "body": {
                "action_type": "V2_SWAP",
                "token_in": "USDC",
                "token_out": "AUSD",
                "amount_in": "100",
                "slippage": "0.5",
            },
        },
        {
            "body": {
                "action_type": "V2_MANAGE",
                "venue": {
                    "type": "VAULT",
                    "vault_address": "0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6",
                },
                "action": models.EarnManageParamsAction.DEPOSIT,
                "amount": "100",
            },
        },
    ], gas_sponsorship=False)

    # Handle response
    print(res)
import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
const result = await compassApiSDK.earn.earnBundle({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
chain: "ethereum",
actions: [
{
body: {
actionType: "V2_TRANSFER_FROM_EOA",
token: "USDC",
amount: "100",
permit2Signature: "0x...",
permit2Nonce: 1706000000,
permit2Deadline: 1706001800,
},
},
{
body: {
actionType: "V2_SWAP",
tokenIn: "USDC",
tokenOut: "AUSD",
amountIn: "100",
slippage: "0.5",
},
},
{
body: {
actionType: "V2_MANAGE",
venue: {
type: "VAULT",
vaultAddress: "0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6",
},
action: "DEPOSIT",
amount: "100",
},
},
],
gasSponsorship: false,
});

console.log(result);
}

run();
curl --request POST \
--url https://api.compasslabs.ai/v2/earn/bundle \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"chain": "ethereum",
"actions": [
{
"body": {
"action_type": "V2_TRANSFER_FROM_EOA",
"amount": "100",
"permit2_deadline": 1706001800,
"permit2_nonce": 1706000000,
"permit2_signature": "0x...",
"token": "USDC"
}
},
{
"body": {
"action_type": "V2_SWAP",
"amount_in": "100",
"slippage": "0.5",
"token_in": "USDC",
"token_out": "AUSD"
}
},
{
"body": {
"action": "DEPOSIT",
"action_type": "V2_MANAGE",
"amount": "100",
"venue": {
"type": "VAULT",
"vault_address": "0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6"
}
}
}
],
"gas_sponsorship": false
}
'
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '0x06A9aF046187895AcFc7258450B15397CAc67400',
chain: 'ethereum',
actions: [
{
body: JSON.stringify({
action_type: 'V2_TRANSFER_FROM_EOA',
amount: '100',
permit2_deadline: 1706001800,
permit2_nonce: 1706000000,
permit2_signature: '0x...',
token: 'USDC'
})
},
{
body: JSON.stringify({
action_type: 'V2_SWAP',
amount_in: '100',
slippage: '0.5',
token_in: 'USDC',
token_out: 'AUSD'
})
},
{
body: JSON.stringify({
action: 'DEPOSIT',
action_type: 'V2_MANAGE',
amount: '100',
venue: {type: 'VAULT', vault_address: '0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6'}
})
}
],
gas_sponsorship: false
})
};

fetch('https://api.compasslabs.ai/v2/earn/bundle', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.compasslabs.ai/v2/earn/bundle",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'chain' => 'ethereum',
'actions' => [
[
'body' => [
'action_type' => 'V2_TRANSFER_FROM_EOA',
'amount' => '100',
'permit2_deadline' => 1706001800,
'permit2_nonce' => 1706000000,
'permit2_signature' => '0x...',
'token' => 'USDC'
]
],
[
'body' => [
'action_type' => 'V2_SWAP',
'amount_in' => '100',
'slippage' => '0.5',
'token_in' => 'USDC',
'token_out' => 'AUSD'
]
],
[
'body' => [
'action' => 'DEPOSIT',
'action_type' => 'V2_MANAGE',
'amount' => '100',
'venue' => [
'type' => 'VAULT',
'vault_address' => '0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6'
]
]
]
],
'gas_sponsorship' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.compasslabs.ai/v2/earn/bundle"

payload := strings.NewReader("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"chain\": \"ethereum\",\n \"actions\": [\n {\n \"body\": {\n \"action_type\": \"V2_TRANSFER_FROM_EOA\",\n \"amount\": \"100\",\n \"permit2_deadline\": 1706001800,\n \"permit2_nonce\": 1706000000,\n \"permit2_signature\": \"0x...\",\n \"token\": \"USDC\"\n }\n },\n {\n \"body\": {\n \"action_type\": \"V2_SWAP\",\n \"amount_in\": \"100\",\n \"slippage\": \"0.5\",\n \"token_in\": \"USDC\",\n \"token_out\": \"AUSD\"\n }\n },\n {\n \"body\": {\n \"action\": \"DEPOSIT\",\n \"action_type\": \"V2_MANAGE\",\n \"amount\": \"100\",\n \"venue\": {\n \"type\": \"VAULT\",\n \"vault_address\": \"0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6\"\n }\n }\n }\n ],\n \"gas_sponsorship\": false\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v2/earn/bundle")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"chain\": \"ethereum\",\n \"actions\": [\n {\n \"body\": {\n \"action_type\": \"V2_TRANSFER_FROM_EOA\",\n \"amount\": \"100\",\n \"permit2_deadline\": 1706001800,\n \"permit2_nonce\": 1706000000,\n \"permit2_signature\": \"0x...\",\n \"token\": \"USDC\"\n }\n },\n {\n \"body\": {\n \"action_type\": \"V2_SWAP\",\n \"amount_in\": \"100\",\n \"slippage\": \"0.5\",\n \"token_in\": \"USDC\",\n \"token_out\": \"AUSD\"\n }\n },\n {\n \"body\": {\n \"action\": \"DEPOSIT\",\n \"action_type\": \"V2_MANAGE\",\n \"amount\": \"100\",\n \"venue\": {\n \"type\": \"VAULT\",\n \"vault_address\": \"0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6\"\n }\n }\n }\n ],\n \"gas_sponsorship\": false\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.compasslabs.ai/v2/earn/bundle")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"chain\": \"ethereum\",\n \"actions\": [\n {\n \"body\": {\n \"action_type\": \"V2_TRANSFER_FROM_EOA\",\n \"amount\": \"100\",\n \"permit2_deadline\": 1706001800,\n \"permit2_nonce\": 1706000000,\n \"permit2_signature\": \"0x...\",\n \"token\": \"USDC\"\n }\n },\n {\n \"body\": {\n \"action_type\": \"V2_SWAP\",\n \"amount_in\": \"100\",\n \"slippage\": \"0.5\",\n \"token_in\": \"USDC\",\n \"token_out\": \"AUSD\"\n }\n },\n {\n \"body\": {\n \"action\": \"DEPOSIT\",\n \"action_type\": \"V2_MANAGE\",\n \"amount\": \"100\",\n \"venue\": {\n \"type\": \"VAULT\",\n \"vault_address\": \"0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6\"\n }\n }\n }\n ],\n \"gas_sponsorship\": false\n}"

response = http.request(request)
puts response.read_body
{
  "actions_count": 3,
  "transaction": {
    "chainId": "0x2105",
    "data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
    "from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
    "gas": "0xf4240",
    "maxFeePerGas": "0x59682f00",
    "maxPriorityFeePerGas": "0x3b9aca00",
    "nonce": "0x5",
    "to": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1",
    "value": "0x0"
  }
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json

Request to execute multiple earn actions in a single atomic transaction.

Supported Action Types

  • V2_TRANSFER_FROM_EOA: Transfer tokens from the owner's EOA to the product account using Permit2. Requires a signed Permit2 message.
  • V2_TRANSFER_TO_EOA: Transfer tokens from the product account back to the owner's EOA. No signature required (product account owns the tokens).
  • V2_TRANSFER_TO_ADDRESS: Transfer ERC20 tokens from the product account to any specified recipient address. No signature required (product account owns the tokens).
  • V2_SWAP: Swap tokens within the product account using 1inch aggregator.
  • V2_MANAGE: Deposit or withdraw from DeFi venues (Aave, Morpho, Vaults, etc.)

Using V2_TRANSFER_FROM_EOA (Deposit to Product Account)

To include a transfer from EOA in your bundle, follow these steps:

  1. One-time setup: Approve Permit2 to spend the token by calling POST /v2/gas_sponsorship/approve_transfer and executing the returned transaction.

  2. Get Permit2 signature: Call POST /v2/earn/transfer with:

    • action: "DEPOSIT"
    • gas_sponsorship: true
    • spender: omit this field (defaults to product account address for bundle use)

    This returns EIP-712 typed data. Sign it with the owner's wallet.

  3. Include in bundle: Add a V2_TRANSFER_FROM_EOA action with the signature and nonce/deadline from the typed data.

The bundle will atomically: pull tokens from EOA → execute subsequent actions.

Using V2_TRANSFER_TO_EOA (Withdraw to EOA)

To transfer tokens from the product account back to the owner's EOA, simply add a V2_TRANSFER_TO_EOA action to your bundle. No signature is required since the product account already owns the tokens.

Specify the exact token amount to transfer.

owner
string
default:0x06A9aF046187895AcFc7258450B15397CAc67400
required

The owner's wallet address that controls the Earn Account.

Example:

"0x06A9aF046187895AcFc7258450B15397CAc67400"

chain
enum<string>
default:ethereum
required

Target blockchain network where the bundled actions will execute.

Available options:
base,
ethereum,
arbitrum,
hyperevm,
tempo,
bsc
Example:

"ethereum"

actions
V2UserOperation · object[]
required

List of actions to bundle. Actions are executed in order.

Minimum array length: 1
Example:
[
{
"body": {
"action_type": "V2_TRANSFER_FROM_EOA",
"amount": "100",
"permit2_deadline": 1706001800,
"permit2_nonce": 1706000000,
"permit2_signature": "0x...",
"token": "USDC"
}
},
{
"body": {
"action_type": "V2_SWAP",
"amount_in": "100",
"slippage": "0.5",
"token_in": "USDC",
"token_out": "AUSD"
}
},
{
"body": {
"action": "DEPOSIT",
"action_type": "V2_MANAGE",
"amount": "100",
"venue": {
"type": "VAULT",
"vault_address": "0x1B4cd53a1A8e5F50aB6320EF34E5fB4D3df7B6f6"
}
}
}
]
gas_sponsorship
boolean
default:false

If true, returns EIP-712 typed data for gas sponsorship. The owner must sign this data and submit to /gas_sponsorship/prepare.

Example:

false

Response

Successful Response

actions_count
integer
required

Number of individual transactions bundled in this execution.

transaction
UnsignedTransaction · object | null

Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false.

Example:
{
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
}
eip_712
BatchedSafeOperationsResponse · object | null

EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true. Owner must sign and submit to /gas_sponsorship/prepare.

Example:
{
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{ "name": "chainId", "type": "uint256" },
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{ "name": "to", "type": "address" },
{ "name": "value", "type": "uint256" },
{ "name": "data", "type": "bytes" },
{ "name": "operation", "type": "uint8" },
{ "name": "safeTxGas", "type": "uint256" },
{ "name": "baseGas", "type": "uint256" },
{ "name": "gasPrice", "type": "uint256" },
{ "name": "gasToken", "type": "address" },
{
"name": "refundReceiver",
"type": "address"
},
{ "name": "nonce", "type": "uint256" }
]
}
}