Saltar a contenido

Euler V2

almanak.connectors.euler_v2

Euler V2 lending protocol connector for Avalanche.

Euler V2 uses ERC-4626 vaults with the Ethereum Vault Connector (EVC) for cross-vault collateral/borrow relationships.

Supported operations: SUPPLY, WITHDRAW, BORROW, REPAY

EulerV2Adapter

EulerV2Adapter(config: EulerV2Config)

Adapter for Euler V2 lending protocol on Avalanche.

Builds raw transaction data for supply, withdraw, borrow, and repay operations against Euler V2 ERC-4626 vaults.

find_vault_for_asset

find_vault_for_asset(
    asset_symbol: str, vault_symbol: str | None = None
) -> EulerV2VaultInfo | None

Find an Euler V2 vault for a given asset.

Parameters:

Name Type Description Default
asset_symbol str

Token symbol (e.g., "USDC", "WAVAX")

required
vault_symbol str | None

Optional specific vault symbol (e.g., "eUSDC-19")

None

Returns:

Type Description
EulerV2VaultInfo | None

EulerV2VaultInfo or None if not found

get_supported_assets

get_supported_assets() -> list[str]

Return list of supported underlying asset symbols.

supply

supply(
    asset: str,
    amount: Decimal,
    vault_symbol: str | None = None,
) -> TransactionResult

Build a deposit transaction for an Euler V2 vault.

Uses ERC-4626 deposit(uint256 amount, address receiver).

Parameters:

Name Type Description Default
asset str

Token symbol to deposit (e.g., "USDC")

required
amount Decimal

Amount in human-readable units

required
vault_symbol str | None

Optional specific vault symbol

None

Returns:

Type Description
TransactionResult

TransactionResult with tx_data for deposit

withdraw

withdraw(
    asset: str,
    amount: Decimal,
    withdraw_all: bool = False,
    vault_symbol: str | None = None,
) -> TransactionResult

Build a withdraw transaction for an Euler V2 vault.

Uses ERC-4626 withdraw(uint256 assets, address receiver, address owner) for specific amounts, or redeem(uint256 shares, address receiver, address owner) with MAX_UINT256 for withdraw_all.

Parameters:

Name Type Description Default
asset str

Token symbol to withdraw

required
amount Decimal

Amount in human-readable units (ignored if withdraw_all=True)

required
withdraw_all bool

If True, redeem all shares

False
vault_symbol str | None

Optional specific vault symbol

None

Returns:

Type Description
TransactionResult

TransactionResult with tx_data for withdraw

borrow

borrow(
    borrow_asset: str,
    borrow_amount: Decimal,
    collateral_vault_address: str | None = None,
    borrow_vault_symbol: str | None = None,
) -> TransactionResult

Build a borrow transaction for Euler V2.

Borrowing requires EVC setup: 1. enableCollateral(account, collateralVault) — register collateral 2. enableController(account, borrowVault) — grant borrow vault access 3. borrow(amount, receiver) — borrow from the vault

These are batched via EVC.batch() for atomicity.

Parameters:

Name Type Description Default
borrow_asset str

Token symbol to borrow

required
borrow_amount Decimal

Amount in human-readable units

required
collateral_vault_address str | None

Address of the collateral vault (must already have deposits)

None
borrow_vault_symbol str | None

Optional specific borrow vault symbol

None

Returns:

Type Description
TransactionResult

TransactionResult with tx_data for EVC batch

repay

repay(
    asset: str,
    amount: Decimal,
    repay_all: bool = False,
    vault_symbol: str | None = None,
) -> TransactionResult

Build a repay transaction for Euler V2.

Uses repay(uint256 amount, address receiver). For full repay, uses type(uint256).max which repays entire debt.

Parameters:

Name Type Description Default
asset str

Token symbol to repay

required
amount Decimal

Amount in human-readable units (ignored if repay_all=True)

required
repay_all bool

If True, repay full debt using MAX_UINT256

False
vault_symbol str | None

Optional specific vault symbol

None

Returns:

Type Description
TransactionResult

TransactionResult with tx_data for repay

EulerV2Config dataclass

EulerV2Config(
    chain: str,
    wallet_address: str,
    default_slippage_bps: int = 50,
)

Configuration for EulerV2Adapter.

EulerV2VaultInfo dataclass

EulerV2VaultInfo(
    vault_symbol: str,
    vault_address: str,
    underlying_symbol: str,
    underlying_address: str,
    decimals: int,
)

Information about an Euler V2 vault.

TransactionResult dataclass

TransactionResult(
    success: bool,
    tx_data: dict | None = None,
    gas_estimate: int = 0,
    description: str = "",
    error: str | None = None,
)

Result of building a transaction.

EulerV2ParseResult dataclass

EulerV2ParseResult(
    success: bool = False,
    error: str | None = None,
    deposit_amount: int = 0,
    deposit_shares: int = 0,
    withdraw_amount: int = 0,
    withdraw_shares: int = 0,
    borrow_amount: int = 0,
    repay_amount: int = 0,
    events: list[dict] = list(),
)

Result of parsing an Euler V2 transaction receipt.

EulerV2ReceiptParser

EulerV2ReceiptParser(
    underlying_decimals: int = 6, **kwargs: Any
)

Parser for Euler V2 transaction receipts.

Extracts deposit, withdraw, borrow, and repay data from on-chain events.

parse_receipt

parse_receipt(
    receipt: dict, vault_address: str | None = None
) -> EulerV2ParseResult

Parse a transaction receipt for Euler V2 events.

Parameters:

Name Type Description Default
receipt dict

Transaction receipt dict with 'logs' list

required
vault_address str | None

Optional vault address to filter events

None

Returns:

Type Description
EulerV2ParseResult

EulerV2ParseResult with extracted data

extract_supply_amount

extract_supply_amount(receipt: dict) -> int | None

Extract supply amount from receipt for ResultEnricher.

Called by ResultEnricher for SUPPLY intents (field: supply_amount).

extract_borrow_amount

extract_borrow_amount(receipt: dict) -> int | None

Extract borrow amount from receipt for ResultEnricher.

Called by ResultEnricher for BORROW intents (field: borrow_amount).

extract_withdraw_amount

extract_withdraw_amount(receipt: dict) -> int | None

Extract withdraw amount from receipt for ResultEnricher.

Called by ResultEnricher for WITHDRAW intents (field: withdraw_amount).

extract_repay_amount

extract_repay_amount(receipt: dict) -> int | None

Extract repay amount from receipt for ResultEnricher.

Called by ResultEnricher for REPAY intents (field: repay_amount).

extract_supply_data

extract_supply_data(
    receipt: dict, vault_address: str | None = None
) -> dict | None

Extract supply data from receipt (legacy API).

extract_borrow_data

extract_borrow_data(
    receipt: dict, vault_address: str | None = None
) -> dict | None

Extract borrow data from receipt (legacy API).

extract_withdraw_data

extract_withdraw_data(
    receipt: dict, vault_address: str | None = None
) -> dict | None

Extract withdraw data from receipt (legacy API).

extract_repay_data

extract_repay_data(
    receipt: dict, vault_address: str | None = None
) -> dict | None

Extract repay data from receipt (legacy API).

__getattr__

__getattr__(name: str) -> Any

PEP 562 lazy attribute access.