Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a625711
stability pool v2 ready for overflow test
rootminus0x1 Feb 8, 2026
1e9bf16
overflow issues detected
rootminus0x1 Feb 9, 2026
c47fc12
migration from v1 to v2 first cut
rootminus0x1 Feb 9, 2026
986e9c9
v2 second draft
rootminus0x1 Feb 9, 2026
d408b2d
v1 & v2 LinearMultipleRewardDistributor tests
rootminus0x1 Feb 9, 2026
2fe6e71
v1 & v2 MultipleRewardCompoundingAccumulator tests
rootminus0x1 Feb 9, 2026
d5a5824
100% LinearMultipleRewardDistributor coverage but there is a bug
rootminus0x1 Feb 9, 2026
98cc420
range tests added
rootminus0x1 Feb 9, 2026
77e340e
added upgrade/gradual migration tests
rootminus0x1 Feb 9, 2026
b1f38c1
formatting
rootminus0x1 Feb 9, 2026
c0f55cc
added identified rare gradual migration test
rootminus0x1 Feb 9, 2026
a16c985
fix tag comparisons
rootminus0x1 Feb 9, 2026
279d178
remove custom address predictions
rootminus0x1 Feb 10, 2026
1a618db
broke up stability pool deployment so implementation can be deployed …
rootminus0x1 Feb 10, 2026
639668b
deploy StabilityPool for gold
rootminus0x1 Feb 10, 2026
ef2df55
regression updates
rootminus0x1 Feb 10, 2026
01bac41
update bao-base
rootminus0x1 Feb 10, 2026
791cccf
Merge branch 'main' into StabilityPool_v2
rootminus0x1 Feb 11, 2026
571fb27
filled gaps in upgrade testing
rootminus0x1 Feb 11, 2026
ac278bd
deployment simulation and testing
rootminus0x1 Feb 11, 2026
4a47c05
stabilitypool upgrade deployment test
rootminus0x1 Feb 11, 2026
5de7fcd
second draft deployment
rootminus0x1 Feb 11, 2026
5b58f5d
fixed block timing issues
rootminus0x1 Feb 11, 2026
1ee5aef
completed the set of stability pools to upgrade
rootminus0x1 Feb 11, 2026
57e55c3
more comprehensive upgrade tests
rootminus0x1 Feb 12, 2026
6e148f1
deployed and transcripts written
rootminus0x1 Feb 12, 2026
9ef18a3
clean up script directory
rootminus0x1 Feb 12, 2026
b6af16a
updated the transaction file to split into the the btc/fxusd leverage…
rootminus0x1 Feb 12, 2026
a06e93e
formatting & regression updates
rootminus0x1 Feb 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"Bash(grep:*)"
]
}
}
28 changes: 28 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"permissions": {
"allow": [
"Bash(forge test:*)",
"Bash(cat:*)",
"WebFetch(domain:dashboard.tenderly.co)",
"Bash(/tmp/investigate_contract.sh:*)",
"Bash(chmod:*)",
"Bash(bash:*)",
"Bash(forge inspect:*)",
"Bash(cast call:*)",
"Bash(forge clean:*)",
"Bash(forge build:*)",
"Bash(./script/check_pool_overflow_risk.py:*)",
"Bash(find:*)",
"Bash(yarn coverage:*)",
"Bash(git ls-tree:*)",
"Bash(git add:*)",
"Bash(python3:*)",
"Bash(cast sig-event:*)",
"Bash(TOPIC0=0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62)",
"Bash(cast logs:*)",
"Bash(jq:*)",
"Bash(script/check-blockchain:*)",
"Bash(echo:*)"
]
}
}
25 changes: 17 additions & 8 deletions .github/workflows/CI-test-foundry-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,26 @@ jobs:
- name: Verify audited sources unchanged
shell: bash
run: |
AUDIT_TAG="audit-2025-07"
# Space-separated list of audit tags. Add new tags as audits complete.
AUDIT_TAGS="audit-2025-07"

# verify the audited src code
git fetch --tags
git rev-parse --verify "${AUDIT_TAG}^{commit}" >/dev/null
git diff --exit-code --stat "${AUDIT_TAG}" -- src
for tag in $AUDIT_TAGS; do
echo "Verifying src/ against tag: ${tag}"
git rev-parse --verify "${tag}^{commit}" >/dev/null
# --diff-filter=DMRT: fail on modified/deleted/renamed/type-changed files,
# but allow new files (additions) that didn't exist at the audit tag.
git diff --exit-code --stat --diff-filter=DMRT "${tag}" -- src

# Verify bao-base's src
cd lib/bao-base-${AUDIT_TAG}
git fetch --tags
git diff --exit-code --stat "${AUDIT_TAG}" -- src
# Verify bao-base's src if corresponding submodule exists
if [ -d "lib/bao-base-${tag}" ]; then
echo "Verifying lib/bao-base-${tag}/src/ against tag: ${tag}"
pushd "lib/bao-base-${tag}" >/dev/null
git fetch --tags
git diff --exit-code --stat --diff-filter=DMRT "${tag}" -- src
popd >/dev/null
fi
done

- name: Run Bao-base CI actions
uses: ./lib/bao-base/.github/actions/test-foundry
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cache/
out/
lcov.info
log/
tmp/
tmp*/

# yarn files (see https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
.pnp.*
Expand Down
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CLAUDE.md

- Do not create functions that are only called once. Inline the logic instead.
120 changes: 120 additions & 0 deletions EXECUTIVE_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Stability Pool Overflow - Executive Summary

## The Problem (30 seconds)

**The Stability Pool will completely break within 1-2 weeks due to an integer overflow.**

- **Current deposits**: 0.097 BTC ($9,700)
- **Reward rate**: 75 tokens/week (fxSAVE)
- **Math**: Small deposits + large rewards = accounting number too big for storage
- **When it breaks**: ALL operations fail (deposits, withdrawals, claims)

## Recommended Solution (30 seconds)

**Queue rewards when overflow would occur, resume when deposits increase.**

- Operations continue working (deposit/withdraw)
- fxSAVE rewards temporarily pause (queued, not lost)
- Auto-resumes when deposits reach ~$240k OR if loss event occurs
- 10 lines of code, zero storage changes, very safe

## Key Metrics

| Metric | Value |
|--------|-------|
| **Time to failure** | 1-2 weeks |
| **Impact if we do nothing** | Pool completely frozen |
| **Impact with solution** | Rewards pause, operations work |
| **Deposits needed to fully fix** | +2.4 BTC ($240k @ $100k/BTC) |
| **Code changes** | ~10 lines, very low risk |
| **Reversible** | Yes |

## User Impact Comparison

### Without Fix (Do Nothing)
- ❌ Cannot deposit
- ❌ Cannot withdraw
- ❌ Cannot claim rewards
- 🔴 **Critical user experience failure**

### With Fix (Queue Solution)
- ✅ Can deposit
- ✅ Can withdraw
- ✅ Can claim other rewards
- ⚠️ **fxSAVE rewards paused until more deposits**
- 🟡 **Degraded but functional**

## What Happens After Deployment

### Scenario 1: No New Deposits
- Pool works normally for deposits/withdrawals
- fxSAVE rewards stop accruing (APY = 0%)
- Rewards queue up (not lost, just delayed)
- Need to communicate: "Rewards paused, deposit to resume"

### Scenario 2: Deposits Arrive
- Need +2.4 BTC ($240k) for full fix
- Queued rewards distribute gradually
- Everything returns to normal

### Scenario 3: Loss Event Occurs
- Natural liquidation loss triggers reset
- Overflow problem solved immediately
- Queued rewards distribute
- Cannot control or predict this

## Communication Strategy

**Week 1 (Post-Deployment):**
> "We've upgraded the Stability Pool to handle edge cases. fxSAVE rewards may pause temporarily if the reward-to-deposit ratio exceeds limits. All funds remain safe and accessible. Deposits help restore normal reward distribution."

**If Rewards Pause:**
> "fxSAVE rewards are temporarily queued due to the current reward-to-deposit ratio. Your rewards are not lost—they will be distributed once the pool reaches optimal deposit levels (~2.5 BTC total). All other operations (deposit, withdraw, claim other tokens) work normally."

**Dashboard Update:**
- Show queue status
- Show deposits needed
- Show progress bar to target

## Risk Assessment

| Risk | Severity | Mitigation |
|------|----------|------------|
| Users confused about paused rewards | Medium | Clear communication, FAQ, dashboard |
| Deposits never arrive | Medium | Incentive programs, reduce reward rate |
| Reputational damage | Low | Transparent communication, funds always safe |
| Technical risk | Very Low | Simple code, no storage changes, well-tested |

## Decision Required

**Question**: Are we comfortable with:
1. fxSAVE rewards potentially pausing?
2. Needing to communicate the pause to users?
3. Depending on either $240k deposits OR natural loss event to fully resolve?

**If YES**: Proceed with queue solution (recommended)
**If NO**: Alternative is to stop/reduce fxSAVE distributions via governance before overflow occurs

## Timeline

- **Today**: Make decision
- **This week**: Deploy fix
- **Week 1-2**: Monitor, communicate if rewards pause
- **Ongoing**: Track deposits, consider incentives if needed

## Bottom Line

**The math is simple**:
```
Small deposits (0.097 BTC) + Large rewards (75 tokens/week) = Overflow
```

**The fix is simple**: Queue rewards until deposits increase

**The trade-off is acceptable**: Paused rewards >> Completely frozen pool

**Recommend**: Deploy queue solution, communicate transparently, monitor deposits.

---

**Questions? Contact the engineering team for technical details or review SOLUTION_ANALYSIS.md for full breakdown.**
Loading