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="0x01E62835dd7F52173546A325294762143eE4a882", 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": "ALL",
            },
        },
    ], gas_sponsorship=False)

    # Handle response
    print(res)
{
  "actions_count": 123,
  "transaction": {
    "chainId": "<string>",
    "data": "<string>",
    "from": "<string>",
    "gas": "<string>",
    "to": "<string>",
    "value": "<string>",
    "nonce": "<string>",
    "maxFeePerGas": "<string>",
    "maxPriorityFeePerGas": "<string>"
  },
  "eip_712": {
    "domain": {
      "chainId": 123,
      "verifyingContract": "<string>"
    },
    "types": {
      "EIP712Domain": [
        {
          "name": "<string>",
          "type": "<string>"
        }
      ],
      "SafeTx": [
        {
          "name": "<string>",
          "type": "<string>"
        }
      ]
    },
    "primaryType": "<string>",
    "message": {
      "to": "<string>",
      "value": "<string>",
      "data": "<string>",
      "operation": 0,
      "safeTxGas": "<string>",
      "baseGas": "<string>",
      "gasPrice": "<string>",
      "gasToken": "<string>",
      "refundReceiver": "<string>",
      "nonce": "<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 Earn Account using Permit2. Requires a signed Permit2 message.
  • V2_TRANSFER_TO_EOA: Transfer tokens from the Earn Account back to the owner's EOA. No signature required (Safe owns the tokens).
  • V2_SWAP: Swap tokens within the Earn Account using 1inch aggregator.
  • V2_MANAGE: Deposit or withdraw from DeFi venues (Aave, Morpho, Vaults, etc.)

Using V2_TRANSFER_FROM_EOA (Deposit to Earn 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 Safe 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 Earn Account back to the owner's EOA, simply add a V2_TRANSFER_TO_EOA action to your bundle. No signature is required since the Safe already owns the tokens.

Use amount: "ALL" to transfer the entire token balance.

owner
string
default:0x01E62835dd7F52173546A325294762143eE4a882
required

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

chain
enum<string>
default:ethereum
required

Target blockchain network where the bundled actions will execute.

Available options:
base,
ethereum,
arbitrum
actions
V2UserOperation · object[]
required

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

Minimum array length: 1
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.

Response

Successful Response

actions_count
integer
required

Number of individual transactions bundled in this execution.

transaction
UnsignedTransaction · object

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

eip_712
BatchedSafeOperationsResponse · object

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