Euler SDK
The Euler V2 SDK is the recommended TypeScript entry point for applications, bots, scripts, and operational tooling built on Euler V2. It reads protocol data, composes Ethereum Vault Connector (EVC) batches, simulates transactions, resolves approvals, and executes plans from frontend or backend clients.
The SDK package lives in the euler-sdks monorepo. Use this page as the high-level entry point, then follow the package docs and runnable examples for implementation details.
What the SDK Provides
- Fetching account, vault, wallet, and market data
- Planning and composing EVC transaction batches
- Resolving approvals (standard
approveand Permit2 paths) - Simulating and estimating transaction plans with optional state overrides
- Swaps, pricing, rewards, labels, FeeFlow, and deployed address resolution
- Oracle adapter metadata and checks (provider, methodology, validation)
The SDK is built with dependency injection: use buildEulerSDK() for the default setup, run individual services in isolation, or plug in custom implementations.
Installation
npm install @eulerxyz/euler-v2-sdkMinimal Setup
import { buildEulerSDK } from "@eulerxyz/euler-v2-sdk";
import { mainnet } from "viem/chains";
const sdk = await buildEulerSDK({
config: {
rpcUrls: {
[mainnet.id]: "https://your-mainnet-rpc",
},
},
});You can also configure RPC URLs with environment variables:
EULER_SDK_RPC_URL_1=https://your-mainnet-rpcCommon Workflows
Read Accounts And Vaults
Use accountService, portfolioService, and vaultMetaService for user and market data.
const { result: account } = await sdk.accountService.fetchAccount(
mainnet.id,
"0xOwner...",
{
populateAll: true,
},
);
const { result: portfolio } = await sdk.portfolioService.fetchPortfolio(
mainnet.id,
"0xOwner...",
);
const { result: vault } = await sdk.vaultMetaService.fetchVault(
mainnet.id,
"0xVault...",
);Use vaultMetaService when you do not know whether an address is an EVault, EulerEarn vault, or another supported vault type.
Services can enrich (populate) their own entities with data from other services. For example, the account service can fetch vault details, token prices, rewards, and other data for user positions.
Plan, Simulate, And Execute Transactions
The executionService builds transaction plans for common Euler actions such as deposit, borrow, repay, withdraw, redeem, multiply, liquidation, debt transfer, and swap-driven flows. Plans separate required approvals from executable EVC batch items.
import { parseUnits } from "viem";
const { result: account } = await sdk.accountService.fetchAccount(
mainnet.id,
"0xOwner...",
);
const plan = sdk.executionService.planDeposit({
account,
vault: "0xVault...",
asset: "0xAsset...",
receiver: "0xReceiverOrSubAccount...",
amount: parseUnits("100", 6),
enableCollateral: true,
});
const simulation = await sdk.executionService.simulateTransactionPlan(
mainnet.id,
account,
plan,
{ stateOverrides: true },
);
if (simulation.canExecute) {
await sdk.executionService.executeTransactionPlan({
plan,
chainId: mainnet.id,
account,
sendTransaction: walletClient.sendTransaction,
signTypedData: walletClient.signTypedData,
});
}executeTransactionPlan processes configured plugins, resolves approvals, requests Permit2 signatures when needed, sends direct contract calls, and submits the final EVC batch.
Use Swaps, Rewards, Plugins, And FeeFlow
Use swapService for quote-backed operations such as repay-with-swap, deposit-with-swap, wallet-to-wallet swaps, wallet swap-and-borrow, wallet swap-and-repay, withdraw-and-swap, redeem-and-swap, swap collateral, and swap debt.
Use rewardsService to fetch campaign data, populate account and vault rewards, and build provider-specific reward claim plans.
Use feeFlowService to fetch FeeFlow state, filter eligible vaults, and build FeeFlow buy plans.
Use plugins for flows that need extra read-path or plan-path behavior, such as pull-based oracle updates.
Examples
The repository ships with runnable examples:
- TypeScript script examples - deposits, borrows, swaps, swap-and-borrow, swap-and-repay, withdraw-and-swap, redeem-and-swap, liquidations, wallet reads, simulations, FeeFlow, and end-to-end execution flows.
- React app example - full frontend using React Query and Wagmi.
Further Reading
Detailed documentation lives in packages/euler-v2-sdk/docs, covering:
- Configuration
- Config Through Env
- Basic Usage
- SDK Architecture Overview
- Services
- Wallet Service
- Execution Service
- Simulations And State Overrides
- Swaps
- Pricing System
- Rewards Service
- Fee Flow Service
- Data Architecture
- Cross-Service Data Population
- Portfolio
- Account Computed Properties
- Caching External Data Queries
- Plugins
- Labels
- Decoding Smart Contract Errors
- Entity Diagnostics