pub mod error;
pub mod history;
pub mod hygiene;
pub mod model;
pub mod ports;
mod chain;
pub use chain::{Chain, Ecosystem};
pub use error::Error;
pub use history::{EventKind, History, HistoryEvent};
pub use model::{
scaled, to_raw, Amount, BorrowedAsset, Complete, Currency, LendingPosition, LiquidityPosition,
LockPosition, Money, NftPosition, Position, PositionStatus, Provenance, Reading, StakePosition,
Staleness, SuppliedAsset, Timestamp, Token, TokenAddress, WalletBalance, YieldKind,
YieldPosition,
};
pub use ports::{ChainProvider, Clock, Ctx, Http, PriceSource, ProtocolAdapter};
pub use alloy_primitives::{self, Address, U256};
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Wallet {
Evm(Address),
Solana(String),
Bitcoin(String),
}
impl Wallet {
pub fn evm(&self) -> Result<Address, Error> {
match self {
Wallet::Evm(a) => Ok(*a),
_ => Err(Error::Permanent {
message: "expected an EVM wallet".into(),
}),
}
}
pub fn solana(&self) -> Result<&str, Error> {
match self {
Wallet::Solana(s) => Ok(s),
_ => Err(Error::Permanent {
message: "expected a Solana wallet".into(),
}),
}
}
pub fn bitcoin(&self) -> Result<&str, Error> {
match self {
Wallet::Bitcoin(s) => Ok(s),
_ => Err(Error::Permanent {
message: "expected a Bitcoin wallet".into(),
}),
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Asset {
Native,
Token(Address),
Mint(String),
}
impl Asset {
#[must_use]
pub fn label(&self) -> String {
match self {
Asset::Native => "native".to_string(),
Asset::Token(a) => format!("{a:#x}"),
Asset::Mint(m) => m.clone(),
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Protocol {
AaveV3,
UniswapV3,
Pendle,
Raydium,
Kamino,
Wallet,
Native,
Nfts,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Source {
Api,
Subgraph,
OnChain,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Capability {
Positions,
History,
Fees,
HealthFactor,
RiskConfig,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Detail {
Presence,
Summary,
Full,
}