Production-grade, upgradeable contracts that back the BUCK savingscoin with on-chain USDC reserves and attested STRC equity. Audited by Cyfrin, Halborn and Spearbit.
- BUCK vs STRC: BUCK = on-chain ERC-20; STRC = MicroStrategy STRETCH note (brokerage custody)
- Savingscoin: Maintains $1.00 via overcollateralization (CR ≥ 1), absorbs STRC volatility with reserve buffers
- CAP pricing: $1.00 when CR ≥ 1, else max(P_STRC/100, CR) → auto-repegs when CR recovers
- Collateral Ratio (CR): (R + HC×V) / L where R = Reserve USDC, V = brokerage STRC value, HC = haircut (set to 0 initially), L = supply
- Primary market: Access-gated stewards mint and refund BUCK through
LiquidityWindow, which prices against a collateral-aware peg (CAP) and enforces fee bands, per-account caps, and oracle freshness. Net USDC flows straight into theLiquidityReserve. - Treasury & solvency controls:
PolicyManagerwatches reserve ratios, attestation health, and oracle feeds. It flips the system between Green/Yellow/Red/Emergency bands, publishing spreads, fees, and mint/refund allowances that the other modules consume. - Collateral truth:
CollateralAttestationis the on-chain copy of the off-chain STRC valuation. It outputs a collateral ratio that powers CAP pricing, oracle strict-mode toggles, and governance alerts. - Governance token:
BUCKis an ERC20Permit token with upgradeable hooks. LiquidityWindow/RewardsEngine are the only minters, DEX transfers are tollable per band, and all balance movements stream into the rewards system. - Yield pass-through: Coupon USDC is routed through
RewardsEngine, skimmed per policy, and reminted as BUCK for holders using balance–time accounting. Anti-snipe timers and mint ceilings prevent distribution gaming. - Access control:
AccessRegistrykeeps a rolling Merkle tree of approved wallets. LiquidityWindow enforces it at mint/refund time, while BUCK leaves secondary trading permissionless. - Price feeds:
OracleAdapterwraps Chainlink + Pyth with an internal price feed, letting PolicyManager demand fresh data only when the system is under-collateralized.
- Approved users: mint/refund at LiquidityWindow (gated, NAV ± spread)
- Public users: trade on Uniswap v2 pool (permissionless, 5bps fee each way)
- All holders: earn yield automatically, claim monthly (min $20)
- DAO arb bot: keeps DEX price near $1.00 via LiquidityWindow arbitrage
| Domain | Contract | Highlights |
|---|---|---|
| Token | src/token/BUCK.sol |
UUPS ERC20 with policy-driven swap fees, access-aware minting, production-mode guardrails, and a rewards hook. |
| Primary Market | src/liquidity/LiquidityWindow.sol |
Access-gated mint/refund desk that prices via CAP, enforces spreads/fees/caps, and moves USDC into/out of the reserve. |
| Treasury Vault | src/liquidity/LiquidityReserve.sol |
Tiered USDC vault with instant withdrawals for refunds, queued treasurer lanes, and role-based accounting. |
| Policy Plane | src/policy/PolicyManager.sol |
Band state machine, CAP calculator, mint/refund caps, DEX fee source, and oracle strict-mode controller. |
| Collateral | src/collateral/CollateralAttestation.sol |
Stores attested STRC value + haircuts, checks staleness, and exposes on-chain collateral ratios. |
| Rewards | src/rewards/RewardsEngine.sol |
Balance-time accounting, coupon ingestion, distribution skim, anti-snipe enforcement, and mint throttle. |
| Compliance | src/access/AccessRegistry.sol |
Merkle-based allowlist with attestor/owner controls and pause/revoke tooling. |
| Oracles | src/oracle/OracleAdapter.sol |
Production oracle multiplexer with Pyth integration and internal price feed. |
| Testing | src/mocks/*.sol |
Mock USDC and access registry to simplify local testing. |
- Role: Canonical BUCK ERC-20. Exposes permit, pause, upgrade, and multicall surfaces while delegating minting to LiquidityWindow/RewardsEngine.
- Key storage & structs
ModuleConfigbundles LiquidityWindow, LiquidityReserve, treasury, PolicyManager, access registry, and rewards hook so governance can rotate dependencies atomically.feeToReservePct,isFeeExempt, anddexPairdefine how swap tolls are applied and routed.productionModeis a one-way switch that forbids clearing critical module addresses.
- Important flows
configureModules(owner) wires dependencies and refreshes the fee-exempt set.addDexPair/removeDexPair/setFeeSplit/setFeeExempttune DEX integrations and fee routing.mint/burnare callable only by LiquidityWindow (primary market) and RewardsEngine (coupon remints); both enforce access checks on recipients._updateoverrides OZ ERC20 logic to apply PolicyManager-provided fees, push proceeds to reserve/treasury, and forward balance deltas to the rewards hook.
- Role: Primary market desk that swaps USDC for BUCK at NAV ± spread and honors access controls, policy bands, and reserve floors.
- Key storage
- Pointers to PolicyManager/BUCK/LiquidityReserve/USDC.
isLiquidityStewardidentifies bot/ops addresses that should skip fees.- Fee split, half-spread, and treasury sink fields mirror PolicyManager outputs but can be overridden during bring-up.
- Important flows
configureFeeSplit,setAccessRegistry,setLiquiditySteward,setUSDC,pauseLiquidityWindow, andunpauseLiquidityWindoware owner tools for runtime tuning.requestMintbatches PolicyManager'sMintParameters, enforces access checks, price ceilings, mint caps, and slippage, then pipes net USDC to the reserve before minting BUCK.requestRefundmirrors the mint path in reverse: checks reserve floors per band, caps refunds, burns BUCK through the token, and queues USDC withdrawals from the reserve._routeFees,_calculateFloor, and_applySpreadare shared helpers that keep fee math centralized.
- Role: On-chain USDC vault that backs instant refunds and stages treasury withdrawals behind role-based delays.
- Key data structures
TierConfigdefines three withdrawal bands (immediate/delayed/slow) as % of current balance plus a delay.WithdrawalRequeststores queued withdrawal metadata (amount, release time, requester, tier).
- Important flows
- Role-aware
recordDepositaccepts flows from LiquidityWindow or treasurers. queueWithdrawalauto-executes LiquidityWindow refunds or enqueues multi-hour withdrawals for treasury roles.executeWithdrawal/cancelWithdrawalgive treasurers + admins deterministic control over queued items.withdrawDistributionSkimis the single path RewardsEngine uses to pull skimmed USDC for the treasury.
- Role-aware
- Role: Control plane for spreads, fees, caps, distributions, and oracle behavior.
- Key data structures
Band,BandConfig, andReserveThresholdsencode the solvency state machine and its parameters.CapSettings,RollingCounter,DerivedCaps, andSystemSnapshotcapture aggregate mint/refund capacity and live health measurements.MintParametersbatches CAP price, spreads, fees, caps, and band info so LiquidityWindow can price in a single call.
- Important flows
refreshBandpulls live supply/reserve/oracle data, re-evaluates the current band, and emitsBandChangedtelemetry.getCAPPricefuses collateral ratios and oracle prices, enforcing attestation freshness and ensuring CAP < $1 whenever CR < 1.checkMintCap/checkRefundCap/recordMint/recordRefundenforce rolling aggregate limits and per-transaction ceilings.syncOracleStrictModetoggles the oracle adapter’s strict-mode flag when CR crosses 1.0, ensuring fresh oracles are only demanded when needed.getMintParameters/getRefundParametersbundle pricing inputs for LiquidityWindow, saving ~20k gas per operation.
- Role: Single source of truth for off-chain STRC valuations and freshness.
- Key storage
V(raw valuation),HC(haircut coefficient), and timestamps for both measurement and submission.healthyStaleness/stressedStalenessthresholds define how often attestations must land depending on CR.- Contract references to BUCK, the reserve, treasury, and USDC allow live CR computation without manual snapshots.
- Important flows
publishAttestation(ATTESTOR_ROLE) validates staleness against the CR implied by the new data, then records valuation.getCollateralRatiocomputes(reserve + HC * V) / liabilities, explicitly excluding treasury USDC.isAttestationStale,timeSinceLastAttestation, andisHealthyCollateralare lightweight views consumed by PolicyManager and client dashboards.- Admin setters (
setContractReferences,setStalenessThresholds,setHaircut,setTreasury) keep the module configurable without redeploys.
- Role: Converts coupon USDC into BUCK rewards using balance-time accounting with anti-snipe protections.
- Key data structures
AccountStatetracks each holder's balance snapshot, locked/unlocked units, reward debt, and last claim/distribution epochs.- Global counters (
accRewardPerUnit,phantomLockedUnits,totalLockedUnits,maxTokensToMintPerEpoch) gate how fast rewards accrue and are minted.
- Important flows
setTokenregisters BUCK as the sole caller foronBalanceChange, ensuring every transfer updates units.onBalanceChange(token hook) routes inflows/outflows into_handleInflow/_handleOutflow, accruing units while applying anti-snipe timing.distributepulls coupon USDC from the caller straight into the reserve, applies PolicyManager's distribution skim, unlocks units, and mints BUCK rewards subject to epoch caps.claim(see contract for overloads) lets users pull unlocked BUCK once they clearminClaimTokensand (optionally) the one-claim-per-epoch policy.- Admin knobs include
configureEpoch,setMaxTokensToMintPerEpoch,setMinClaimTokens,setAccountExcluded,pauseDistribute, and treasury/reserve hookups.
- Role: Merkle-based allowlist enforced by LiquidityWindow at mint/refund time.
- Key storage
merkleRoot,currentRootId, andattestorcapture the latest attestations published by the compliance service._allowedmapping records which wallets have successfully proven membership.
- Important flows
setRoot(attestor) publishes a new tree and bumps the rootId.registerWithProofverifies Merkle proofs for end users.revoke,revokeBatch, andforceAllowgive the attestor/owner levers to keep the set accurate.- Pausable controls let governance halt new registrations without affecting existing allowances.
- Role: Normalize external feed data for PolicyManager and LiquidityWindow.
- Highlights
- Chainlink is the primary source; Pyth is an optional failover. Both outputs are scaled to 18 decimals.
strictModeis toggled directly by PolicyManager: when CR < 1.0, oracle freshness is enforced; otherwise it is ignored to save gas and handle downtimes gracefully.- Manual fallback pricing plus
_lastPriceUpdateBlocklet LiquidityWindow reject same-block CAP manipulations. - Test mocks are available in
src/mocks/for local and testnet deployments.
MockUSDC.solandMockAccessRegistry.sollet the Foundry test suite simulate external dependencies without deploying the full stack.