Composable DeFi primitives for building sophisticated financial workflows on Flow blockchain
⚠️ This repo is in beta and not yet intended for use in production systems.
DeFiActions provides a set of standardized interfaces that act as "money LEGOs" for the Flow ecosystem.
The framework abstracts away protocol-specific complexities, allowing developers to focus on building sophisticated DeFi strategies rather than wrestling with individual protocol integrations. Each component represents a fundamental financial operation that can be seamlessly connected with others.
Built natively for Flow's Cadence smart contract language, DeFiActions leverages Flow's unique capabilities including resource-oriented programming and upcoming features like scheduled callbacks to enable truly autonomous financial workflows.
DeFiActions is currently in beta status and undergoing active development. Interfaces may change based on community feedback and real-world usage patterns discovered during the FLIP review process.
- No Backwards Compatibility Guarantee: Interfaces may evolve significantly as the framework matures
- Breaking Changes Expected: Current implementations should be considered experimental
- Production Use Discouraged: Not recommended for production-ready Mainnet deployments until interfaces stabilize
- Community Feedback Welcome: Developer input is actively sought to refine the interfaces before final release
- Experiment on Low Stakes Implementations: Build and test integrations locally as much as possible and with minimal funds in pre-production contracts if on Mainnet
- Stay Updated: Monitor repository changes and FLIP discussions for interface updates
- Provide Feedback: Share implementation experiences to help shape the final interface design
| Contract | Testnet | Mainnet |
|---|---|---|
| DeFiActions | 0x4c2ff9dd03ab442f | 0x92195d814edf9cb0 |
| DeFiActionsMathUtils | 0x4c2ff9dd03ab442f | 0x92195d814edf9cb0 |
| DeFiActionsUtils | 0x4c2ff9dd03ab442f | 0x92195d814edf9cb0 |
| FungibleTokenConnectors | 0x5a7b9cee9aaf4e4e | 0x1d9a619393e9fb53 |
| EVMNativeFLOWConnectors | 0xb88ba0e976146cd1 | 0xcc15a0c9c656b648 |
| EVMTokenConnectors | 0xb88ba0e976146cd1 | 0xcc15a0c9c656b648 |
| SwapConnectors | 0xaddd594cf410166a | 0x0bce04a00aedf132 |
| IncrementFiSwapConnectors | 0x49bae091e5ea16b5 | 0xefa9bd7d1b17f1ed |
| IncrementFiFlashloanConnectors | 0x49bae091e5ea16b5 | 0xefa9bd7d1b17f1ed |
| IncrementFiPoolLiquidityConnectors | 0x49bae091e5ea16b5 | 0xefa9bd7d1b17f1ed |
| IncrementFiStakingConnectors | 0x49bae091e5ea16b5 | 0xefa9bd7d1b17f1ed |
| BandOracleConnectors | 0x1a9f5d18d096cd7a | 0xf627b5c89141ed99 |
| UniswapV2Connectors | 0xfef8e4c5c16ccda5 | 0x0e5b1dececaca3a8 |
DeFiActions defines five fundamental interface types that represent core DeFi operations:
- Source - Provides tokens on demand (e.g., withdraw from vault, claim rewards)
- Sink - Accepts tokens up to capacity (e.g., deposit to vault, repay loan)
- Swapper - Exchanges one token type for another (e.g., DEX trades, cross-chain swaps)
- PriceOracle - Provides price data for assets (e.g., external price feeds, DEX prices)
- Flasher - Issues flash loans with callback execution (e.g., arbitrage, liquidations)
- AutoBalancer - Automated rebalancing system that combines Sources, Sinks, and PriceOracles to maintain value equilibrium around the historical value of deposits & withdrawal
- Quote - Data structure for swap price estimates and execution parameters
- ComponentInfo - Metadata structure containing component type, identifier, and hierarchical information about inner components
- UniqueIdentifier - Traceability mechanism for identifying and tracking component operations across workflows
All DeFiActions components execute within single transactions, ensuring that complex multi-step financial operations either complete entirely or fail safely without partial execution.
Interfaces provide minimal behavioral promises, prioritizing flexibility and composability over strict guarantees. This allows for graceful handling of edge cases and enables robust workflows across diverse protocols, though it does put the responsibility of output validation on the consumer.
Built using Cadence structs rather than resources, DeFiActions components are lightweight, easily copyable, and efficient and flexible to compose.
Comprehensive event emission enables full workflow tracing and debugging, with standardized events for deposits, withdrawals, swaps, flash loans, and component alignment operations.
To understand DeFiActions, start with these key files:
cadence/contracts/interfaces/DeFiActions.cdc- Core interface definitions and documentationcadence/contracts/connectors/FungibleTokenConnectors.cdc- Basic Source/Sink implementations for FungibleToken vaultscadence/contracts/connectors/increment-fi/IncrementFiSwapConnectors.cdc- Example protocol adapter for IncrementFi DEX integration
- Start with the interfaces: Review the core primitive definitions in
DeFiActions.cdc - Study the connectors: Examine
FungibleTokenConnectors.cdcfor basic implementation patterns - Explore protocol connectors: See how external protocols integrate via the connector examples
- Check the tests: Browse
cadence/tests/for usage patterns and workflow examples
-
Install dependencies
flow deps install
-
Run tests
make test -
Run specific test suites
# Test core functionality flow test cadence/tests/DeFiActions_test.cdc # Test FungibleToken connectors flow test cadence/tests/FungibleTokenConnectors_test.cdc # Test protocol connectors flow test cadence/tests/IncrementFiSwapConnectors_test.cdc
- Flow configuration: See
flow.jsonfor network and contract configurations - Test accounts: Tests use temporary accounts created during test execution
- Mock contracts: Test implementations available in
cadence/tests/contracts/
Basic Vault Operations:
VaultSink- Deposits tokens to a FungibleToken vault with capacity limitsVaultSource- Withdraws tokens from a FungibleToken vault with minimum balance protectionVaultSinkAndSource- Combined deposit/withdrawal functionality for a single vault
Protocol Connectors:
IncrementFiSwapper- DEX integration for token swapping via IncrementFiBandPriceOracle- Price feed integration with Band Protocol oracleEVMSwapper- UniswapV2-style swapping on Flow EVM
Additional usage patterns will be linked here once they become available.
- FLIP Document: DeFiActions FLIP - TBD