Skip to content

defi collateral issue - #5

Merged
thewealthyplace merged 17 commits into
mainfrom
feature/bstx-defi-collateral-issue-2
Feb 24, 2026
Merged

defi collateral issue#5
thewealthyplace merged 17 commits into
mainfrom
feature/bstx-defi-collateral-issue-2

Conversation

@thewealthyplace

Copy link
Copy Markdown
Owner

closes #2

Implements core oracle with spot rate calculation using
(total-stx * 1_000_000) / total-bstx-supply at 6 decimal precision.
Includes circular observation buffer (10 slots), halted state flag,
and authorized-updater mechanism.
Implements cumulative price accumulator pattern (Uniswap V2-style).
TWAP = delta(cumulative_price) / delta(block_height) over any window.
Supports up to 20 checkpoints in circular buffer for flexible window queries.
Implements deviation check (per-update), velocity check (rolling window),
and manual admin trip/reset. Configurable thresholds (default 5% deviation,
10% velocity over 100 blocks). Emits structured print events on every trip.
… listing

Records bSTX listing proposal on-chain: 75% LTV, 80% liquidation threshold,
5% liquidation bonus. Full lifecycle (DRAFT→SUBMITTED→ACTIVE→PASSED/REJECTED),
signalling vote tally, and duplicate-vote prevention. Seeds default proposal at deploy.
…flow

Implements add/remove liquidity, STX→bSTX swap with 0.05% fee tier, and
price-range enforcement (0.95–1.05 tick bounds). Records provider positions,
accrued fees, and pool reserves. Seeded with Bitflow-compatible pool structure.
…n Clarinet.toml

Adds deployment entries for:
- bitstake-bstx-oracle
- bitstake-bstx-oracle-twap
- bitstake-oracle-circuit-breaker
- bitstake-alex-governance
- bitstake-bitflow-pool
Covers: correct 1:1 rate, premium calculation, zero-supply error,
observation recording, frequency guard, non-owner rejection,
authorized-updater delegation, TWAP after multiple observations,
circuit breaker read-only state, and get-rates snapshot.
…esholds

Tests: initial state, price within/outside deviation threshold, breaker
open/close state, manual trip, invalid threshold params, non-owner rejections,
and last-price read-only.
Covers: default proposal seeding, LTV params, proposal creation,
non-owner rejection, invalid LTV params, full status lifecycle,
voting (for/against/duplicate), and invalid transition guard.
Covers: initial stats, liquidity add/remove, reserve accounting, position
recording, slippage guard, pool-paused rejection, non-owner removal,
STX→bSTX swap, quote helper, tick-range price update guard.
…only functions

Exposes per-pool and cross-pool total stacked STX so the bSTX oracle can
compute the exchange rate purely from on-chain data without off-chain inputs.
…e feed

Covers: initial zero state, push-price success, non-owner rejection,
zero-supply rejection, cumulative price growth, TWAP window queries,
checkpoint slot population, and write-index advancement.
…cked

Verifies oracle data-feed helpers: fresh pool returns 0, unknown pool errors,
aggregate of 0 before deposits, single-pool deposit reflection, and
cross-pool sum correctness.
Covers oracle interface (spot + TWAP), circuit breaker integration pattern,
ALEX governance proposal steps, Bitflow pool parameters and usage,
deployment order, and security considerations (TWAP manipulation, depeg risk,
liquidation cascade, oracle freshness).
Includes: summary, motivation, proposed LTV/liquidation parameters,
oracle design rationale, risk analysis (depeg, liquidation cascade,
oracle freshness, smart contract risk), and implementation checklist.
Documents Phase 1 DeFi integrations (ALEX, Bitflow, Velar), oracle usage,
Bitflow pool interaction, and links to the full integration guide.
Updates roadmap to mark oracle and DeFi contracts as complete.
Renames workflow to 'Contract Tests', adds oracle-tests job that runs
after clarinet-test, covering all 5 new test files:
oracle spot/TWAP, circuit breaker, ALEX governance, and Bitflow pool.
@thewealthyplace
thewealthyplace merged commit 9ab1afd into main Feb 24, 2026
2 of 6 checks passed
@thewealthyplace
thewealthyplace deleted the feature/bstx-defi-collateral-issue-2 branch February 24, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable bSTX as collateral in Stacks DeFi protocols (ALEX, Bitflow)

1 participant