smart-contracts/backlog/tasks/task-4 - Port-FlowDampener-...

41 lines
1.1 KiB
Markdown

---
id: TASK-4
title: Port FlowDampener to Solidity
status: To Do
assignee: []
created_date: '2026-04-03 21:39'
labels:
- solidity
- core
- risk
dependencies:
- TASK-1
references:
- /home/jeffe/Github/myco-bonding-curve/src/primitives/flow_dampening.py
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Translate src/primitives/flow_dampening.py to Solidity.
Simplest of the core primitives — exponential outflow memory to prevent bank runs.
Core logic:
- dampened_rate = base_rate * exp(-k * recent_outflow / total_reserve)
- Track cumulative outflow with exponential decay per block
- Configurable decay half-life and sensitivity parameter k
Integrates with bonding curve sell() and tranche redeem() as a rate limiter.
Should be a library or modifier that other contracts can use.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Outflow dampening matches Python model behavior
- [ ] #2 Decay correctly resets over configured half-life
- [ ] #3 Can be used as modifier on sell/redeem functions
- [ ] #4 Gas overhead < 10k per check
<!-- AC:END -->