How aegisfinance/aegis works
Project Type & Purpose
• This is a backend canisters project built for the Internet Computer (IC) blockchain. It implements the core logic for Aegis Finance’s decentralized exchange platform.
• The system supports several key use cases: managing user tokens (ICP, ckBTC, ckETH), options trading, insurance contracts, and staking of AEGIS tokens.
• That the frontend is maintained in another repo (Aegis-Dapp), so the focus here is solely on backend canisters and supporting libraries.
Main Components
• Canisters: The heart of the system is its multiple independent canisters:
– Accounts Canister: Manages user tokens including deposit, withdrawal, and inter-chain conversions.
– Main Canister: Handles staking functions for $AEGIS tokens.
– Insurance Canister: Implements buying/selling of insurance contracts.
– Options Canister: Implements trading options contracts.
• Ledgers & Minters: There are dedicated components and associated WASM modules for various ledgers (ckbtc, cketh, ckusdt, icp) plus minter utilities. These interact with the accounts canister and support token conversions.
• Libraries: Several shared libraries such as “blackscholes-rust” (for pricing models and options calculations), ic_ledger_utils, management_canister, minter_utils, serializer, and stable_memory provide core functionalities and are reused across the system.
• Declarations & Interfaces: The “declarations” directory and corresponding TypeScript declarations indicate a strong typed interface for canister interactions (e.g., the candid interface files for each canister).
Relationships and Interactions
• Data flow should show API interactions between these canisters where necessary (for instance, the accounts canister will interact with the ledgers/minter modules for token management).
• External services include:
– Bitcoin Node: A separate external component (managed via scripts such as bitcoin.sh) that supports BTC node operations and integration.
– External blockchains’ assets (BTC, ETH, etc.) are interfaced via the ledger canisters.
• The libraries are shared resources used by one or more canisters. Group these as supporting components that interact with the core canisters.
Architectural Patterns & Design Principles
• The design leverages a microservices-like, canister-based architecture where each major function (tokens, insurance, options, staking) is encapsulated in its own module.
• There is a clear separation of concerns: core business logic exists in canisters, while shared utilities are abstracted away in libraries.
• The use of candid interface definitions and declarations implies a strong API contract between components.
• Deployment and testing scripts suggest automated builds, deployment pipelines, and thorough unit/integration tests.
Final Details for the Engineer
• Canister-based component is clearly separated to emphasize independence.
• Be as detailed as possible—don’t shy away from breaking down internal modules (e.g., within the accounts canister, show the subdivision into API routes, lifecycle events, wallet management, etc.) if space allows.
• Interplay between blockchain integrations (Bitcoin node, multi-chain assets) and the decentralized canister deployments.