rehype
1
总安装量
1
周安装量
#53642
全站排名
安装命令
npx skills add https://github.com/rustydotwtf/doppler-skills --skill rehype
Agent 安装分布
opencode
1
claude-code
1
Skill 文档
Source References: Code citations link to raw GitHub files pinned to commit
988dab4. To fetch specific lines:curl -s "<url>" | sed -n 'START,ENDp'
Rehype Doppler Hook
Use this skill for anything involving Doppler’s Rehype hook: configuring fee distributions, decoding swap flows, running invariant suites, or shipping deployments.
When To Activate
- User references “rehype”, Doppler hooks, fee distributions, buybacks, or beneficiary payouts
- Tasks touch
src/dopplerHooks/RehypeDopplerHook.sol,IRehypeHook.sol, or related deployments/tests - Need to explain hook-driven swap behavior, collect fees, or update pool configuration
Prerequisites
- Doppler repo checked out and current (
whetstoneresearch/doppler) - Foundry toolchain installed for
forge/cast - Access to the Airlock + DopplerHookInitializer environment when mutating on-chain state
- Uniswap V4 Pool Manager RPC endpoint for simulations or deployments
Quick Start
- Identify the pool asset + numeraire by inspecting
DopplerHookInitializer.getState(asset). - Confirm Rehype is enabled for the pool (
ON_INITIALIZATION_FLAG | ON_SWAP_FLAG). - Load current fee distribution with
RehypeDopplerHook.getFeeDistributionInfo(poolId)to baseline percentages. - Move to the relevant workflow below (configuration, fee collection, testing, deployment).
Core Workflows
Configure / Tune Fee Distribution
- Gather desired percentages (asset buyback, numeraire buyback, beneficiary, LP) that must sum to
WAD(1e18). - Call
setFeeDistribution(poolId, ...)from thebuybackDstaddress (stored ingetPoolInfo[poolId].buybackDst).- Only the
buybackDstcan update fee distribution; expectSenderNotAuthorizedon mismatch.
- Only the
- Record reasoning + math (ideally in governance artifacts) because improper splits can stall swaps.
- See Configuration for calldata templates and sanity checks.
Note: The previous setFeeDistributionByBeneficiary() function has been removed. Fee distribution updates are now controlled exclusively by buybackDst.
Collect Beneficiary Fees
- Resolve the target asset (the Doppler token) and call
RehypeDopplerHook.collectFees(asset). - The hook transfers accumulated
beneficiaryFees0/1tobuybackDstand zeroes out the counters. - Confirm ERC20 balances + hook storage match expectations before/after collection.
- Document tx hash for accounting.
Collect Airlock Owner Fees (5% Protocol Fee)
- The Rehype hook automatically splits 5% of all swap fees to the Airlock owner (stored separately as
airlockOwnerFees0/1). - The Airlock owner calls
RehypeDopplerHook.claimAirlockOwnerFees(asset)to claim accumulated fees. - Only the current
airlock.owner()can call this function; expectSenderNotAirlockOwneron mismatch. - Returns
(fees0, fees1)indicating amounts transferred.
Understand Swap Flow / Debugging
_onSwapcollects swap output fees, executes asset + numeraire buybacks, rebalances, and reinvests LP before crediting beneficiary balances.- Use
_collectSwapFeesmath to estimate deductions:fee = outputAmount * customFee / 1e6. - Fee Split: 5% of collected fees go to
airlockOwnerFees, remaining 95% go tofees0/1for distribution. - Inspect
getHookFees(poolId)for:fees0/fees1(distributable fees for buybacks/LP/beneficiary)beneficiaryFees0/1(accumulated beneficiary share, claimable viacollectFees)airlockOwnerFees0/1(5% protocol fee, claimable viaclaimAirlockOwnerFees)
- Troubleshoot common errors in the table below.
Testing Changes
- Run targeted unit tests:
forge test --match-contract RehypeDopplerHook -vv. - Execute invariants from
test/invariant/rehype/usingforge test --match-contract RehypeInvariants(ERC20) andRehypeInvariantsETH(native path). - For fuzzing issues, consult handler design + risk matrix in Testing.
- Capture seed(s) that reproduce failures; investigate
_rebalanceFees, settlement paths, or_collectSwapFeesunderflows.
Deploy / Upgrade Hook Instances
- Edit
doppler/script/deployments.config.tomlwith the target chain parameters (CreateX, initializer, pool manager). - Run
forge script script/DeployRehypeDopplerHook.s.sol --rpc-url <network> --broadcast --sig "run()". - Script enforces Create3 deterministic address parity; expect revert if mismatch.
- After broadcasting, update
doppler/Deployments.mdwith the new address + commit hash. - Details live in Deployment.
Troubleshooting Cheat Sheet
| Symptom | Likely Cause | Fix |
|---|---|---|
FeeDistributionMustAddUpToWAD() revert |
Percentages do not sum to 1e18 |
Normalize weights before calling setters |
SenderNotAuthorized() revert |
Caller is not the buybackDst for this pool |
Query getPoolInfo[poolId].buybackDst and switch signer |
SenderNotAirlockOwner() revert |
Caller is not the airlock owner when claiming owner fees | Query airlock.owner() and switch signer |
Swaps revert with INSUFFICIENT_INPUT_AMOUNT |
Hook tried to rebalance more than held | Inspect getHookFees vs. ERC20 balances; rerun invariants |
Hook stuck with large fees0/fees1 but no beneficiary accrual |
_simulateSwap failing or pool lacks liquidity |
Verify Quoter path, pool balances, or temporarily disable LP reinvest via config |
| Deploy script exits early | config.get("is_testnet") false (prod guard) |
Remove guard only when cleared for production |
References
- Configuration playbooks
- Testing + invariants guide
- Deployment runbook
- Source of truth:
doppler/src/dopplerHooks/RehypeDopplerHook.sol,doppler/src/interfaces/IRehypeHook.sol,doppler/test/invariant/rehype/SPECIFICATION.md