Guidance for AI coding agents (Claude Code, Codex, Cursor, Copilot, Gemini CLI) working in this repository. Loaded into agent context automatically — keep it concise.
DeFiActions is a Cadence framework of composable "money LEGO" primitives (Source, Sink,
Swapper, PriceOracle, Flasher, AutoBalancer) for building DeFi workflows on Flow. Core
interfaces live in cadence/contracts/interfaces/DeFiActions.cdc; protocol adapters live
under cadence/contracts/connectors/. The repo also contains a Foundry-managed Solidity
side under solidity/ for EVM-side contracts used by the EVM connectors. Status: beta —
README explicitly warns "not yet intended for use in production systems."
All Cadence commands are driven by the Makefile:
make test— run the full Cadence test suite with coverage (flow test --cover --covercode="contracts" --coverprofile="coverage.lcov" ./cadence/tests/*_test.cdc)make lint— runflow cadence lintover everycadence/contracts/**/*.cdcmake ci—lint+test(the job run by.github/workflows/cadence_tests.yml)flow deps install --skip-alias --skip-deployments— install Flow dependencies (matches CI step; plainflow deps installis shown in README)flow test cadence/tests/<Specific>_test.cdc— run one suite
Solidity side (Foundry, configured via foundry.toml):
forge fmt --check— format check (CI gate,.github/workflows/test.yml)forge build --sizes --via-ir --optimize— build (CI gate)- Sources in
solidity/src/, tests insolidity/test/, libs insolidity/lib/(git submodules: forge-std, flow-sol-utils, openzeppelin-contracts, aave-v3-core, v2-core, v2-periphery, More-Vaults — see.gitmodules)
CI uses Flow CLI v2.15.3 and Go 1.23.x (.github/workflows/cadence_tests.yml).
cadence/
contracts/
interfaces/DeFiActions.cdc # All core interfaces + AutoBalancer resource
utils/ # DeFiActionsUtils, ERC4626Utils, EVMAbiHelpers
connectors/
FungibleTokenConnectors.cdc # VaultSink, VaultSource, VaultSinkAndSource
SwapConnectors.cdc # MultiSwapper, SwapSource, SwapSink, SequentialSwapper
band-oracle/ # BandOracleConnectors.cdc
increment-fi/ # Swap, Staking, PoolLiquidity, Flashloan connectors
evm/ # UniswapV2/V3, ERC4626 (PriceOracle/Sink/Swap),
# EVMNativeFLOW, EVMToken, EVMAmountUtils
evm/morpho/ # MorphoERC4626 Sink + Swap connectors
tests/ # *_test.cdc suites, fork/ (mainnet-fork tests),
# contracts/ (mocks: MockOracle, MockSwapper,
# TokenA/B/C, TestTokenMinter, ExecutionCallbackRecorder)
transactions/ # Per-connector tx scripts (12 subfolders)
scripts/ # Read-only query scripts per connector family
solidity/
src/ test/ lib/ # Foundry layout (per foundry.toml)
| Name | Kind | Line |
|---|---|---|
Sink |
struct interface |
267 |
Source |
struct interface |
299 |
Swapper |
struct interface |
345 |
PriceOracle |
struct interface |
430 |
Flasher |
struct interface |
449 |
Quote |
struct interface |
329 |
UniqueIdentifier |
struct |
130 |
ComponentInfo |
struct |
151 |
AutoBalancer |
resource |
708 |
The framework is primarily struct-based for lightweight composition, except
AutoBalancer, which is a resource (conforms to FungibleToken.Receiver/Provider,
ViewResolver.Resolver, Burner.Burnable, FlowTransactionScheduler.TransactionHandler).
Do not claim "everything is a struct."
- AutoBalancer is a resource, not a struct. It wraps an inner
@{FungibleToken.Vault}?and must be destroyed viaBurner.burn()so the inner vault'sburnCallback()runs (see field comments around line 725–727). - Weak guarantees. Source/Sink/Swapper interfaces intentionally promise very little; output validation is the caller's responsibility (README "Weak Guarantees Philosophy").
testingalias is0x0000000000000009for every DeFiActions contract inflow.jsonexceptBandOracleConnectorsandSwapConnectors(both0x0000000000000007) and the test token contractsTokenA/B/C+TestTokenMinter(0x0000000000000010).- Deployed addresses live in
flow.jsonaliases, not in code. Verified mainnet/testnet pairs (partial list):DeFiActions/DeFiActionsUtils— mainnet0x6d888f175c158410, testnet0x0b11b1848a8aa2c0FungibleTokenConnectors— mainnet0x0c237e1265caa7a3, testnet0x4cd02f8de4122c84SwapConnectors— mainnet0xe1a479f0cb911df9, testnet0xad228f1c13a97ec1BandOracleConnectors— mainnet0xe36ef556b8b5d955, testnet0xbb76ea2f8aad74a0EVMNativeFLOWConnectors/EVMTokenConnectors— mainnet0x1a771b21fcceadc2, testnet0xbee3f3636cec263a- IncrementFi connectors have
testingaliases only — no mainnet/testnet inflow.json(README lists mainnet/testnet addresses0xe844c7cf7430a77c/0x494536c102537e1ewhich are not mirrored intoflow.json; treat the README as the source for those).
mainnet-forknetwork is defined inflow.json(host127.0.0.1:3569, forkmainnet). Fork-only tests live incadence/tests/fork/.- Coverage output lands at
coverage.lcovat repo root (Makefiletesttarget). - Lint gate (
make lint) greps for"Lint passed"inflow cadence lintoutput — a lint warning fails CI. emulator-account.pkeyis committed intentionally (test key, not a real credential).- Solidity submodules must be initialized (
git submodule update --init --recursive) beforeforge build— CI usessubmodules: recursiveon checkout.
solidity/lib/**— git submodules (forge-std, openzeppelin-contracts, aave-v3-core, v2-core, v2-periphery, flow-sol-utils, More-Vaults)emulator-account.pkey— emulator test key, required as-is byflow.jsoncoverage.lcov— generated bymake testfoundry.lock— Foundry lockfile