Repository navigation
Description
Summary
Let node operators onboard holding only USDC: have decdn setup auto-swap USDC → TOKEN for exactly the capacity bond via the live TOKEN/USDC DEX pool, then bond. Today an operator must independently source TOKEN before setup can bond — a real friction wall, since TOKEN is an illiquid project token while USDC is trivially acquirable.
Feasible: yes. Most of the machinery already exists. The cleanest version needs no new on-chain contract.
Venue note (see #1000). The original plan assumed the protocol's Balancer V3 80/20 TOKEN/USDC pool. But Balancer V3 is not deployed on Arbitrum Sepolia (the initial testnet target per
CLAUDE.md) — only Uniswap V3 is live there (factory0x248AB79…, QuoterV20x2779a0…). So the swap step must be venue-neutral: route through Uniswap V3 on the testnet now, and switch to the Balancer V3 pool later once it lands on Arb Sepolia — exactly the rollout #1000 takes for the buyback burner. The shared dependency is the pool/venue, not any one router.
Why this is mostly already built
decdn setup --mbps Nalready computes the exact TOKEN needed. It reads the bond from the on-chainbondRequired(mbps)curve (bond = k × Mbps^α, defaultsk=12.6,α=1.2) and bonds it — seecrates/common/src/cli/setup.rsandcrates/cli/src/commands/setup.rs, per ADR 019 Phase 2. So the "--declareMbpsto know how much token people need" ask is already satisfied by--mbps— the swap target (bondRequired(mbps), plus a slippage buffer) is known before any tx is sent.- A TOKEN/USDC pool exists on whichever venue is live. The protocol's intended venue is a Balancer V3 80/20 TOKEN/USDC weighted pool (1% fee, Treasury-custodied) operated by
BuybackBurnerBalancerV3(ADR 018 liquidity strategy,contracts/src/BuybackBurnerBalancerV3.sol). On the Arb Sepolia testnet that pool does not yet exist; the live venue there is Uniswap V3 (see Make BuybackBurner venue-neutral and add BuybackBurnerUniswapV3 #1000). The CLI must target the venue that is actually deployed for the configured chain.
Proposed approach (recommended: CLI-orchestrated, no new contract)
Add an opt-in flag, e.g. decdn setup --mbps N --pay-bond-with usdc (name TBD). The CLI then, before bonding:
- Compute
target = bondRequired(mbps)(already done) + a slippage buffer. - Resolve the swap venue from chain config (Uniswap V3 on Arb Sepolia today; Balancer V3 where deployed). The venue selection should live in chain context (
crates/cli/src/commands/chain_ctx.rs) alongside the existing token/router addresses, not be hard-coded to Balancer. USDC.approve(<router>, maxUsdcIn)(for Uniswap V3 SwapRouter02; the Balancer V3 Router path approves via Permit2, asBuybackBurnerBalancerV3already does).- Execute an exact-out swap so the operator receives precisely the bond amount and leftover USDC is refunded:
- Uniswap V3:
SwapRouter02.exactOutputSingle({tokenIn: USDC, tokenOut: TOKEN, fee, recipient, amountOut: target, amountInMaximum: maxUsdcIn, sqrtPriceLimitX96: 0}). - Balancer V3:
Router.swapSingleTokenExactOut(pool, USDC→TOKEN, exactAmountOut=target, maxAmountIn, deadline, …).
- Uniswap V3:
- Proceed with the existing
approve(CapacityBond) → bond → declareMbps → registerflow.
This is fully self-custodial (operator signs every tx; no protocol funds at risk), reuses the live pool, and adds no governance/admin surface.
Why not reuse BuybackBurner: it's exact-in, keeper/governance-gated, and burns the TOKEN it buys — it can't deliver TOKEN to an operator's bond. The shared asset is the pool/venue, not the contract. (The venue-neutral burner refactor in #1000 is the on-chain analogue of the same "abstract the venue" move this CLI flow needs.)
Open design questions (call these out before implementation)
- Venue abstraction. The swap step needs a small venue trait (
exact_out(token_in, token_out, amount_out, max_in, …)) with Uniswap V3 and Balancer V3 implementations, selected by chain config. Keep parity with how Make BuybackBurner venue-neutral and add BuybackBurnerUniswapV3 #1000 abstracts the burner so both surfaces share one mental model. [your call] on whether to land Uniswap-only first and add Balancer behind the same trait later. - Slippage / MEV. Operator swaps need
amountInMaximum(exact-out) +deadline, and should route through private RPC (Flashbots Protect / MEV-Share), consistent with the ADR 018 buyback policy. How is the slippage bound surfaced — preset,--max-slippage-bps, or governance-tunable band? [your call] - Pool depth at large tiers. Depth depends on the live venue (the Balancer seed is ~100M TOKEN / ~$250K USDC; the Uniswap V3 testnet pool seed is a separate operational parameter). Small tiers are negligible (10 Mbps ≈ 200 TOKEN), but big tiers move price hard against a thin pool: 1 Gbps ≈ 50K TOKEN, 10 Gbps ≈ 795K TOKEN. Auto-swap should likely be gated to small/entry tiers (or hard-fail above a price-impact threshold) and point larger operators at OTC/CEX. This also interacts with concurrent onboarding draining the pool. [your call]
- ADR posture. ADR 019 frames
setupas "thin orchestration … submits no transaction the primitives don't." A swap is a new primitive, so this needs an ADR 019 amendment (or a small new ADR) recording the swap step, the venue-neutral selection, slippage policy, and tier gating. Pairs with the existing operator-onboarding/bootstrap programs in ADR 026 § Bootstrap mechanism. - Failure atomicity. Swap and bond are separate txs; if bond fails after a successful swap the operator simply holds TOKEN — acceptable, but document it and make
setupresumable.
Scope
- In: opt-in
decdn setupflag, venue-neutral CLI swap orchestration (Uniswap V3 SwapRouter02 on Arb Sepolia now, Balancer V3 Router where live), slippage/deadline/private-RPC handling, tier gating, ADR note. - Out: any new on-chain contract; production/testnet pool deployment + seeding (tracked under ADR 018 and Make BuybackBurner venue-neutral and add BuybackBurnerUniswapV3 #1000); changing the bond curve.
Pointers
crates/cli/src/commands/setup.rs,crates/cli/src/commands/bond.rs,crates/cli/src/commands/chain_ctx.rs,crates/common/src/cli/setup.rscontracts/src/BuybackBurnerBalancerV3.sol,contracts/src/BondMath.sol,contracts/src/CapacityBond.sol- Venue-neutral burner + Uniswap V3 path: Make BuybackBurner venue-neutral and add BuybackBurnerUniswapV3 #1000
- ADR 019, ADR 018, ADR 026
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon Jun 25, 2026
🎯 Triage report
A COLLABORATOR-authored UX enhancement to eliminate the TOKEN acquisition barrier during node onboarding by adding an opt-in
--pay-bond-with usdcflag todecdn setup. The CLI would orchestrate a USDC→TOKENswapSingleTokenExactOuton the protocol's live Balancer V3 80/20 pool before bonding — no new on-chain contracts, self-custodial, fully reversible. The proposal is well-scoped and references all existing machinery. Three open design decisions are explicitly flagged and must be resolved before implementation can safely begin.📊 Assessment
decdn setuponboarding flowenhancement,economics,technical,missing-decision,medium,clialready accurately applied;missing-decisionis correct since the ADR amendment is explicitly unresolved🔗 Similar issues
decdn setup— guided node onboarding wizard (ADR 019 Phases 1–2) #933 (related) — Closed parent issue that built the basedecdn setupwizard (ADR 019 Phases 1–2). This issue extends it by adding a swap primitive step.💡 Notes and suggestions
Design decisions to resolve before assigning for implementation:
Slippage / MEV parameter form. Three options:
--max-slippage-bpsCLI flag with a hardcoded default (e.g., 150 bps = 1.5%) — simplest and consistent with self-custodial posture; recommended starting pointPrivate-RPC (Flashbots Protect / MEV-Share) should be opt-in via config, mirroring ADR 018 buyback policy.
Tier-gate threshold. Based on issue's own numbers (pool seed ~100M TOKEN / ~$250K USDC):
Suggested policy: simulate price impact before submitting (query pool reserves via Balancer V3
querySwapSingleTokenExactOut); fail with a clear message ("price impact X% exceeds threshold; use OTC/CEX for this tier") if above a configurable limit (e.g., 5%).ADR posture. ADR 019 is now implemented (Implement
decdn setup— guided node onboarding wizard (ADR 019 Phases 1–2) #933 closed). A swap step is a new primitive beyond ADR 019's "thin orchestration over existing primitives" charter. A new ADR (next available: 040) recording swap step, slippage policy, tier-gate, and failure-atomicity posture is cleaner than amending 019, and avoids reopening a completed ADR.Implementation sub-tasks (post design-decision sign-off):
--pay-bond-with usdcflag + USDC balance preflight tocrates/cli/src/commands/setup.rsswapSingleTokenExactOutcall incrates/incentive/or a newswap.rsmodule incliquerySwapSingleTokenExactOutfor price-impact simulation before submittingmaxAmountIn+deadlinecalculation; plumb optional private-RPC configsetupresumable: on retry, if TOKEN balance ≥bondRequired(mbps), skip swap and go straight to bondFailure atomicity (already called out in issue): "swap done, bond reverted" leaves the operator holding TOKEN — acceptable. The resume path (detect sufficient TOKEN on retry, skip swap) is the correct fix; no rollback mechanism needed.
Relevant reference: [Balancer V3 Router
swapSingleTokenExactOutAPI]((docsv3.balancer.fi/redacted) — exact-out variant guarantees the operator receives preciselybondRequired(mbps)tokens, with leftover USDC refunded.Add this agentic workflows to your repo
To install this agentic workflow, run
[-]cli: auto-swap USDC → TOKEN bond during `decdn setup` via the protocol's Balancer pool[/-][+]cli: auto-swap USDC → TOKEN bond during `decdn setup` via the live DEX pool (Uniswap V3 / Balancer V3)[/+]fix(incentive)/fix(cli): harden USDC bond-swap venues per PR review (#…
fix(incentive): enforce Uniswap swap deadline via multicall + idempot…
fix(incentive,cli): make swap quoter optional and rename --swap-pool-…
fix(cli): USDC setup dry-run no longer prompts or bails early (#991)
refactor(cli): --swap-venue ValueEnum + reuse pick for balancer pool (#…
fix(common): declare USDC bond-swap fields on BlockchainConfig (#991)
fix(incentive): U512 spot_in + reset swap allowances on all paths (#991)
fix(cli,incentive): resolve 7 open USDC-bond-swap review threads (#991)
feat(cli): decdn setup --pay-bond-with usdc — auto-swap USDC→TOKEN bo…