Silo V2¶
almanak.framework.connectors.silo_v2
¶
Silo V2 connector for Almanak SDK.
Silo V2 is an isolated lending protocol on Avalanche where each market consists of exactly two assets paired together in separate ERC-4626 vaults.
Key concepts: - Each market is a pair of two Silo vaults (silo0 + silo1) - Depositing into one silo enables borrowing from the paired silo - No shared pool — bad debt is isolated per market - CollateralType: 0=Collateral (borrowable), 1=Protected (non-borrowable)
SiloV2Adapter
¶
Adapter for Silo V2 lending protocol on Avalanche.
Provides supply, withdraw, borrow, and repay operations for Silo V2 isolated lending markets.
find_market
¶
find_market(
asset0_symbol: str | None = None,
asset1_symbol: str | None = None,
) -> SiloV2MarketInfo | None
Find a market by asset pair symbols.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset0_symbol
|
str | None
|
First asset symbol (collateral side) |
None
|
asset1_symbol
|
str | None
|
Second asset symbol (borrow side) |
None
|
返回:
| 类型 | 描述 |
|---|---|
SiloV2MarketInfo | None
|
Market info or None if not found |
find_silo_for_asset
¶
find_silo_for_asset(
asset_symbol: str, market_name: str | None = None
) -> tuple[SiloV2MarketInfo, str, int] | None
Find the silo address for a given asset.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset_symbol
|
str
|
Token symbol (e.g., "USDC", "WAVAX") |
必需 |
market_name
|
str | None
|
Optional market name to narrow lookup |
None
|
返回:
| 类型 | 描述 |
|---|---|
tuple[SiloV2MarketInfo, str, int] | None
|
Tuple of (market_info, checksummed_silo_address, asset_index) or None |
supply
¶
supply(
asset: str,
amount: Decimal,
market_name: str | None = None,
collateral_type: int = COLLATERAL_TYPE_COLLATERAL,
) -> TransactionResult
Build a deposit transaction for Silo V2.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset
|
str
|
Token symbol to deposit (e.g., "USDC") |
必需 |
amount
|
Decimal
|
Amount in human-readable units |
必需 |
market_name
|
str | None
|
Optional market name (e.g., "WAVAX/USDC") |
None
|
collateral_type
|
int
|
0=Protected (non-borrowable), 1=Collateral (borrowable) |
COLLATERAL_TYPE_COLLATERAL
|
返回:
| 类型 | 描述 |
|---|---|
TransactionResult
|
TransactionResult with encoded calldata |
withdraw
¶
withdraw(
asset: str,
amount: Decimal,
market_name: str | None = None,
withdraw_all: bool = False,
collateral_type: int = COLLATERAL_TYPE_COLLATERAL,
) -> TransactionResult
Build a withdraw transaction for Silo V2.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset
|
str
|
Token symbol to withdraw |
必需 |
amount
|
Decimal
|
Amount in human-readable units (ignored if withdraw_all) |
必需 |
market_name
|
str | None
|
Optional market name |
None
|
withdraw_all
|
bool
|
If True, withdraw all available balance |
False
|
collateral_type
|
int
|
0=Protected, 1=Collateral |
COLLATERAL_TYPE_COLLATERAL
|
返回:
| 类型 | 描述 |
|---|---|
TransactionResult
|
TransactionResult with encoded calldata |
borrow
¶
Build a borrow transaction for Silo V2.
The caller must deposit collateral separately before borrowing. This method only builds the borrow() call on the borrow silo.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
collateral_asset
|
str
|
Collateral token symbol (identifies the market pair) |
必需 |
borrow_asset
|
str
|
Token to borrow |
必需 |
borrow_amount
|
Decimal
|
Amount to borrow in human-readable units |
必需 |
返回:
| 类型 | 描述 |
|---|---|
TransactionResult
|
TransactionResult with encoded calldata |
repay
¶
repay(
asset: str,
amount: Decimal,
market_name: str | None = None,
repay_all: bool = False,
) -> TransactionResult
Build a repay transaction for Silo V2.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset
|
str
|
Token to repay |
必需 |
amount
|
Decimal
|
Amount to repay (ignored if repay_all) |
必需 |
market_name
|
str | None
|
Optional market name |
None
|
repay_all
|
bool
|
If True, repay using MAX_UINT256 |
False
|
返回:
| 类型 | 描述 |
|---|---|
TransactionResult
|
TransactionResult with encoded calldata |
redeem_shares
¶
redeem_shares(
shares: int,
market_name: str | None = None,
silo_address: str | None = None,
collateral_type: int = COLLATERAL_TYPE_COLLATERAL,
) -> TransactionResult
Build a redeem transaction using exact share amount.
Used for withdraw_all to avoid ERC-4626 rounding issues.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
shares
|
int
|
Exact share amount to redeem |
必需 |
market_name
|
str | None
|
Market name for metadata |
None
|
silo_address
|
str | None
|
The silo vault address |
None
|
collateral_type
|
int
|
0=Protected, 1=Collateral |
COLLATERAL_TYPE_COLLATERAL
|
返回:
| 类型 | 描述 |
|---|---|
TransactionResult
|
TransactionResult with encoded calldata |
get_market_info
¶
Get market info for a given asset.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset_symbol
|
str
|
Token symbol |
必需 |
market_name
|
str | None
|
Optional market name to narrow lookup |
None
|
返回:
| 类型 | 描述 |
|---|---|
SiloV2MarketInfo | None
|
SiloV2MarketInfo or None |
get_silo_address
¶
Get the silo vault address for a given asset.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
asset_symbol
|
str
|
Token symbol |
必需 |
market_name
|
str | None
|
Optional market name |
None
|
返回:
| 类型 | 描述 |
|---|---|
str | None
|
Checksummed silo address or None |
SiloV2Config
dataclass
¶
Configuration for Silo V2 adapter.
SiloV2MarketInfo
dataclass
¶
SiloV2MarketInfo(
market_name: str,
silo_config: str,
silo0_address: str,
silo1_address: str,
asset0_symbol: str,
asset0_address: str,
asset1_symbol: str,
asset1_address: str,
)
Information about a Silo V2 market pair.
SiloV2Position
dataclass
¶
SiloV2Position(
market_name: str,
silo_address: str,
asset_symbol: str,
asset_address: str,
amount: Decimal,
is_collateral: bool = True,
)
A position in a Silo V2 market.
TransactionResult
dataclass
¶
TransactionResult(
success: bool,
tx_data: dict | None = None,
gas_estimate: int = 0,
description: str = "",
error: str | None = None,
)
Result of building a Silo V2 transaction.
SiloV2ReceiptParser
¶
Parser for Silo V2 transaction receipts.
Extracts deposit, withdraw, borrow, and repay data from on-chain events.
parse_receipt
¶
Parse a transaction receipt for Silo V2 events.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
receipt
|
dict
|
Transaction receipt dict with 'logs' list |
必需 |
silo_address
|
str | None
|
Optional silo address to filter events. If filtering yields no events, automatically retries without the filter (handles proxy/router patterns). |
None
|
返回:
| 类型 | 描述 |
|---|---|
SiloV2ParseResult
|
SiloV2ParseResult with extracted data |
extract_supply_amount
¶
Extract supply amount from receipt for ResultEnricher.
Called by ResultEnricher for SUPPLY intents (field: supply_amount).
extract_borrow_amount
¶
Extract borrow amount from receipt for ResultEnricher.
Called by ResultEnricher for BORROW intents (field: borrow_amount).
extract_withdraw_amount
¶
Extract withdraw amount from receipt for ResultEnricher.
Called by ResultEnricher for WITHDRAW intents (field: withdraw_amount).
extract_repay_amount
¶
Extract repay amount from receipt for ResultEnricher.
Called by ResultEnricher for REPAY intents (field: repay_amount).
extract_supply_data
¶
Extract supply data from receipt (legacy API).
extract_borrow_data
¶
Extract borrow data from receipt (legacy API).
extract_withdraw_data
¶
Extract withdraw data from receipt (legacy API).
extract_repay_data
¶
Extract repay data from receipt (legacy API).