Skip to content

feat(core): define Position, LiquidationOpportunity, FlashLoanSource, SwapRoute#27

Merged
obchain merged 7 commits into
feat/01-scaffold-workspacefrom
feat/02-core-types
Apr 24, 2026
Merged

feat(core): define Position, LiquidationOpportunity, FlashLoanSource, SwapRoute#27
obchain merged 7 commits into
feat/01-scaffold-workspacefrom
feat/02-core-types

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented Apr 21, 2026

Closes #3

Normalized types shared across the workspace:

  • ProtocolId — enum naming the lending protocol (Venus only for v0.1)
  • Position — a single borrow position with health factor + bonus
  • FlashLoanSource — Balancer / Aave / Uniswap enum
  • SwapRoute — planned collateral→debt DEX swap with slippage floor
  • LiquidationParams — protocol-specific Venus variant
  • LiquidationOpportunity — ready-to-execute liquidation

All types derive Serialize/Deserialize for config + logging. Addresses + amounts use alloy::primitives::{Address, U256}.

Depends on #2 (feat/01-scaffold-workspace). Base is the scaffold branch; will rebase onto main once #2 merges.

obchain added 2 commits April 21, 2026 17:47
… SwapRoute

Add the normalized types shared across the workspace:

  - ProtocolId: enum naming the lending protocol (Venus only for v1)
  - Position: a single borrow position with health_factor and bonus
  - FlashLoanSource: Balancer / Aave / Uniswap flash loan providers
  - SwapRoute: planned collateral->debt DEX swap with slippage protection
  - LiquidationOpportunity: a profitable, ready-to-execute liquidation

All types derive Serialize/Deserialize for config + logging compatibility.
Addresses and amounts use alloy::primitives::{Address, U256}.
obchain added 2 commits April 22, 2026 20:04
- Untrack CLAUDE.md; root-level CLAUDE.md stays local-only.
- .gitignore: *.md / !README.md glob enforces the markdown policy.
- .gitignore: add Foundry artifacts (out/, cache/, broadcast/) at
  root and under contracts/ so forge build/script output stays local.
- .gitignore: add node_modules/ for any npm-based contract deps
  or operator tooling.

Closes #56 #57 #58 #59
- FlashLoanSource::UniswapV3 → PancakeSwapV3 (BSC has no Uniswap V3);
  note the BSC fee tiers (100/500/2500/10000).
- Add #[non_exhaustive] to FlashLoanSource and ProtocolId so new
  variants are not semver-breaking for downstream exhaustive matches.
- Replace LiquidationOpportunity.net_profit_usd_cents: u64 with
  net_profit_wei: U256 denominated in the debt-token base unit; USD
  conversion is a reporting-layer concern and must not drive ranking.
- Implement Ord / PartialOrd / PartialEq / Eq on LiquidationOpportunity
  so it can live in a profit-ordered BinaryHeap (max-heap pops the
  highest net_profit_wei first).
- SwapRoute.pool_fee: u32 (sentinel 0) → Option<u32>; None for
  fee-less routes, Some(bps) otherwise — removes the 0-vs-100-bps
  ambiguity on PancakeSwap V3.
- Rustdoc every public field with units and source-of-truth notes;
  mark LiquidationOpportunity #[must_use].

Closes #64 #65 #66 #67 #68 #69
obchain and others added 3 commits April 24, 2026 12:31
chore: repo bootstrap — README, CLAUDE.md, LICENSE, .gitignore
chore: scaffold Cargo workspace with three crates
# Conflicts:
#	Cargo.lock
#	crates/charon-core/Cargo.toml
@obchain obchain merged commit 1f92936 into feat/01-scaffold-workspace Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant