Skip to content

futarchy-fi/futarchy-liquidity-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Futarchy Liquidity Manager

Audit-oriented smart contract package for generic futarchy liquidity management.

The core idea is that LPs deposit a company token and collateral once, receive FLM shares, and the manager handles spot liquidity, conditional YES/NO migration during an official proposal, and return to spot after settlement.

Public deposits are accepted only in spot mode and in the vault's existing two-asset proportion. Redemption is always available, including conditional and emergency modes. Share changes fully unwind active positions first so principal, fees, and idle balances remain pro-rata; callers supply no adapter ticks, slippage, deadlines, or initialization prices.

Layout

  • src/core/ - generic audited FLM state machine.
  • src/sources/ - official proposal source and on-chain proposal validation.
  • src/oracles/ - deadline-bounded Reality/CTF settlement helpers.
  • src/adapters/ - protocol-specific liquidity adapters.
  • src/interfaces/ - minimal external dependency interfaces.
  • script/ - JSON-configured deployment and Safe batch helpers.
  • test/ - focused unit tests and protocol mocks.
  • docs/ - design notes, threat model, and audit-scope material.

Audit Boundary

Primary audit scope:

  • src/core/FutarchyLiquidityManager.sol
  • src/sources/FutarchyOfficialProposalSource.sol
  • src/oracles/DeadlineBoundedRealityProxy.sol
  • src/interfaces/*.sol

Adapter audit scope:

  • src/adapters/SwaprAlgebraLiquidityAdapter.sol

Out of scope for this package:

  • FAO sale contracts.
  • SnapshotX arbitration/evaluator contracts.
  • Frontend and SDK code.
  • Deployment scripts for a specific organization.

FAO should integrate with this package by deploying/configuring these generic contracts. This package should not import FAO-specific contracts.

Test

git submodule update --init --recursive
forge test

Run Gnosis fork checks explicitly:

RUN_GNOSIS_FORK_TESTS=true forge test --match-path 'test/fork/*'

Generate a deployment from explicit JSON config:

FLM_ALGEBRA_FACTORY=0x... \
forge script script/DeployAlgebraPoolStabilityGuard.s.sol \
  --rpc-url gnosis \
  --broadcast

# Deploy the canonical permissionless factory once with the reviewed shared dependencies.
PRIVATE_KEY=... \
FLM_POSITION_MANAGER=0x... \
FLM_ALGEBRA_FACTORY=0x... \
FLM_CONDITIONAL_ROUTER=0x... \
FLM_POOL_STABILITY_GUARD=0x... \
FLM_WRAPPED_NATIVE=0x... \
forge script script/DeployFutarchyLiquidityManagerFactory.s.sol \
  --rpc-url gnosis \
  --broadcast

# Put the shared guard and factory addresses in the deploy config before validating.
tools/validate-configs.sh --deploy config/gnosis.production.json

FLM_DEPLOY_CONFIG=config/gnosis.production.json \
FLM_DEPLOY_OUTPUT=deployments/flm.gnosis.json \
forge script script/DeployFutarchyLiquidityManager.s.sol \
  --rpc-url gnosis \
  --broadcast

Generate a Safe transaction-builder batch:

tools/validate-configs.sh --batch config/batches/bootstrap.production.json

FLM_BATCH_CONFIG=config/batches/bootstrap.production.json \
FLM_BATCH_OUTPUT=out/flm-safe-batch.json \
forge script script/BuildLiquidityOperationBatch.s.sol

About

Audit-oriented futarchy liquidity manager contracts

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages