Skip to content

Add staking-vault skill — deploy your own ERC-4626 staking vault#381

Open
0xAxiom wants to merge 24 commits into
BankrBot:mainfrom
0xAxiom:add-axiom-staking-vault-skill
Open

Add staking-vault skill — deploy your own ERC-4626 staking vault#381
0xAxiom wants to merge 24 commits into
BankrBot:mainfrom
0xAxiom:add-axiom-staking-vault-skill

Conversation

@0xAxiom
Copy link
Copy Markdown
Contributor

@0xAxiom 0xAxiom commented May 17, 2026

Summary

Generic, parameterized port of the StakedAxiom (xAXIOM) contract that any agent or project can lift, configure, and ship as a share-price-rebase staking vault for their own ERC-20.

Reward distribution = single stakeToken.transfer(vault, amount) call that rebases share price pro rata. No claim step, no reward debt, no per-holder gas. ERC-4626 spec-compliant so aggregator UIs (Yearn, Beefy, Morpho) work out of the box.

What's in the skill

  • src/StakingVault.sol — ERC-4626 vault, ~200 lines. Aave-style two-step cooldown, JIT-resistant (cooldown rebases on inbound shares — defeats the "tiny-cooldown-then-huge-deposit" attack), inflation-attack hardened (_decimalsOffset = 6), Ownable2Step. Owner can adjust cooldown params (bounded ≤ 30 days / ≥ 1 day) and rescue non-stake tokens. Cannot mint, burn, pause, upgrade, or rescue the stake token.
  • script/Deploy.s.sol — env-driven forge script (STAKE_TOKEN, OWNER, VAULT_NAME, VAULT_SYMBOL, optional COOLDOWN_PERIOD / WITHDRAW_WINDOW).
  • test/StakingVault.t.sol — 24 forge tests, all passing on solc 0.8.28 with OZ 5.6.1. Covers share math, pro-rata rewards, cooldown gating, JIT regression, transfer-during-cooldown blocking, inflation-attack mitigation, and ERC-4626 maxRedeem / maxWithdraw spec compliance.
  • scripts/init.sh — installs forge-std + OpenZeppelin/openzeppelin-contracts, builds, runs tests.
  • scripts/deploy.sh — wraps forge script with .env loading; supports base / base_sepolia / mainnet.
  • references/SECURITY.md — full audit findings (1 critical, 1 medium, 1 low accepted, 1 informational — all fixed and regression-tested).
  • references/integration.md — reward-flow patterns (daily cron / streaming / governance), frontend display notes (convertToAssets for user balances, cooldownStatus for UI state machine), operational checklist.

Reference deployment

Originally deployed as xAXIOM on Base. Live frontend at https://clawbots.org/stake. This skill is the public, generalized port — name and symbol lifted to constructor args so any project can spin up their own xToken with their own ticker/cooldown.

Test plan

  • forge build clean on solc 0.8.28
  • forge test -vv — 24/24 passing
  • Reward distribution test confirms pro-rata share-price rebase (10/30/60 split → 200/600/1200 after 1000 reward)
  • JIT attack regression: tiny-cooldown + huge mid-cooldown deposit reverts on redeem
  • Inflation attack regression: 1-wei seed + 1000-token donation, victim's 100-token deposit redeems > 99 tokens
  • Transfer-during-cooldown blocked (sender-side guard)
  • maxRedeem / maxWithdraw spec-compliant (0 outside withdraw window)
  • Owner cannot rescue stake token
  • Owner cannot extend cooldownPeriod beyond MAX_COOLDOWN = 30 days or set withdrawWindow below MIN_WITHDRAW_WINDOW = 1 day
  • Manual deploy to Base Sepolia via bash scripts/deploy.sh base_sepolia (requires deployer-side .env — not part of CI)

🤖 Generated with Claude Code

0xAxiom added 24 commits March 18, 2026 14:17
…T.md

- Updated SKILL.md with complete API reference (700+ lines)
- Updated HEARTBEAT.md with detailed automation checklist
- Added copy-paste ready code snippets for all major languages
- Included comprehensive error handling and troubleshooting
- Added performance analytics and copy-trading strategies
- Complete integration examples for Bankr wallet and Net Protocol

Supports: signal publishing, copy-trading, provider registration, performance tracking, webhooks, cross-posting to Net Protocol feeds.
- Transaction-verified trading signals on Base
- Complete API coverage: registration, signal publishing, leaderboards
- Copy-paste ready code snippets for bash/JS
- Heartbeat integration examples
- Real-time polling and webhook support
- Cross-integration with Bankr and Net Protocol skills

Addresses agent onboarding by making trading signals discoverable to all OpenClaw agents.
Generic, parameterized port of the StakedAxiom (xAXIOM) contract any agent
can lift, configure, and ship for their own ERC-20.

- src/StakingVault.sol — ERC-4626 vault, ~200 lines. Aave-style cooldown,
  JIT-resistant (cooldown rebases on inbound shares), inflation-attack
  hardened (_decimalsOffset = 6), Ownable2Step. Owner can adjust cooldown
  params (bounded) and rescue non-stake tokens. Cannot mint, burn, pause,
  upgrade, or rescue the stake token.
- script/Deploy.s.sol — env-driven forge script (STAKE_TOKEN, OWNER,
  VAULT_NAME, VAULT_SYMBOL, COOLDOWN_PERIOD, WITHDRAW_WINDOW).
- test/StakingVault.t.sol — 24 forge tests, all passing on solc 0.8.28
  with OZ 5.6.1. Covers share math, pro-rata rewards, cooldown gating,
  JIT regression, inflation-attack mitigation, ERC-4626 spec compliance.
- scripts/init.sh — installs forge-std + OZ, builds, runs tests.
- scripts/deploy.sh — wraps forge script with .env loading; supports
  base / base_sepolia / mainnet.
- references/SECURITY.md — full audit (1 critical, 1 medium, 1 low
  accepted, 1 informational — all fixed and regression-tested).
- references/integration.md — reward-flow patterns (cron / streaming /
  governance), frontend display notes, operational checklist.

Reward distribution is a single `stakeToken.transfer(vault, amount)` call
that rebases share price pro rata — no claim step, no reward debt, no
per-holder gas. ERC-4626 spec-compliant so aggregator UIs (Yearn, Beefy,
Morpho) work out of the box.

Reference deployment: xAXIOM on Base, frontend at clawbots.org/stake.
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.

1 participant