Skip to main content

What They are

Product Accounts are isolated on-chain accounts for each DeFi product (Earn, Borrow, Trade, etc.). When a user first uses Earn, we create an Earn Product Account. If they later use Borrow, they get a separate Borrow Product Account. Both accounts are controlled by the user’s main wallet. Compass never holds custody of the funds. Compass just orchestrates creation and transaction routing.

Why Use Them

  1. Transaction Bundling: Bundle any workflow, such as approvals, swap, and deposit in a single transaction. Save gas and improve UX.
  2. Gas Sponsorship: All transactions within Product Accounts can be gas-sponsored. Users never need ETH, you can sponsor their gas across deposits, withdrawals, swaps, and borrows.
  3. No Fund Intermingling: Your Earn positions can’t get liquidated because of your Leverage positions. Each product operates in isolation.
  4. Clean Accounting: Separate on-chain addresses per product simplify compliance and auditing.
  5. Independent Development: Add new products without refactoring existing integrations.

How They Work

Product Accounts are controlled by your user’s wallet. Compass orchestrates account creation and transaction routing. Users sign all transactions. Compass never holds keys or custody. This happens all through API calls.

Create your first Earn account

Create an Earn Account on Base. The API returns an unsigned transaction that you must sign and broadcast separately.
Note
Creating an Earn Account is usually the first step before users can interact with DeFi venues. If you want to sponsor gas, you can request EIP-712 typed data from the API and have a relayer submit it; here we keep it simple so the owner covers their own gas.

Prerequisites

1

Install Dependencies

Install the required packages.
npm install @compass-labs/api-sdk dotenv viem
2

Set Environment Variables

Create a .env file:
# .env
COMPASS_API_KEY="your_compass_api_key"
WALLET_ADDRESS="0xYourWalletAddress"
PRIVATE_KEY="your_private_key"
BASE_RPC_URL="https://mainnet.base.org"

Implementation

1

Import Libraries & Environment Variables

2

Initialize SDK

3

Get Unsigned Transaction

Request an unsigned transaction to create an Earn Account. The owner and sender are the same address (no gas sponsorship).
4

Sign and Broadcast Transaction

Sign the transaction with your private key and broadcast it to the Base network.

Full Code

Fund your Earn Account

Transfer tokens from your wallet to your Earn Account. This example deposits 2 USDC from the owner wallet into the Earn Account, without gas sponsorship. You can choose to sponsor gas via the API when you want a relayer to pay for execution. Sign and broadcast the transaction: