Skip to content

V2.1.1 — F-04 follow-up: multi-hop swap path#3

Merged
kimandy7778 merged 3 commits into
mainfrom
feat/v2.1.1-multihop
Jun 25, 2026
Merged

V2.1.1 — F-04 follow-up: multi-hop swap path#3
kimandy7778 merged 3 commits into
mainfrom
feat/v2.1.1-multihop

Conversation

@kimandy7778

Copy link
Copy Markdown
Collaborator

Summary

V2.1.0 의 F-04 fix (reward claim + auto-compound) 가 single-hop UniV3 swap 만 지원해서 COMP / MORPHO 같은 reward 토큰의 direct USDC pool 유동성 부족으로 mainnet revert 되는 issue 를 V2.1.1 multi-hop path 지원으로 해결합니다.

Compound mainnet fork probe (2026-06-25) 에서 발견. prod 진입 전에 fix.

Commits

  • 1efafbb feat(v2.1.1): contracts — multi-hop swap path
  • (test) test(v2.1.1): Compound real fork (3) + 5 strategy mock unit (11)
  • 21736a7 docs(v2.1.1): SOKEN_AUDIT.md F-04 follow-up

Key changes

  1. BaseStrategy._swapAndReinvest 시그니쳐: (rewardToken, uint24 poolFee, ...)(rewardToken, bytes calldata swapPath, ...). UniV3 exactInput(path) 호출.
  2. _validateSwapPath helper: path 의 length / endpoint 강제 (rewardToken → USDC).
  3. Errors.InvalidPath 추가.
  4. 5 strategy claimAndCompound 시그니쳐 변경.
  5. hardhat.config.ts viaIR: true (FluidStrategy stack 회피).

Test plan

  • npx hardhat compile — 47 files OK
  • npx hardhat test — 103 passing (10 신규: 11 mock + 3 fork-pending without FORK)
  • FORK=true npx hardhat test test/v2/Strategy.claim.fork.spec.ts — 3 passing
  • (reviewer) docs/SOKEN_AUDIT.md F-04 follow-up subsection 검토

After merge

  1. v2.1.1 tag + release
  2. Soken 에 v2.1.1 tag URL + SOKEN_AUDIT.md (F-04 follow-up 포함) 송부 (대표님)
  3. v2.1.1 prod 배포 사이클 (audit 통과 후)

V2.1.0 의 single-hop UniV3 swap 이 COMP / MORPHO 같은 reward 토큰의 direct
USDC pool 유동성 부족으로 mainnet revert 되는 issue 발견 (Compound fork
probe). prod 진입 전에 multi-hop path 지원으로 fix.

BaseStrategy._swapAndReinvest
  (rewardToken, uint24 poolFee, amountIn, minOut)
  → (rewardToken, bytes calldata swapPath, amountIn, minOut)
  내부: dexRouter.exactInputSingle → dexRouter.exactInput(path)

_validateSwapPath helper
  - length 검사 (20 + N*23, ≥ 43)
  - 첫 20 바이트 == rewardToken
  - 마지막 20 바이트 == address(underlyingAsset) (= USDC)
  → 악의적 Keeper 의 endpoint 우회 차단

ISwapRouter
  + exactInput(ExactInputParams) — path bytes 형식 multi-hop

Errors
  + InvalidPath (V2.1.1)

5 strategy 시그니쳐 변경 (poolFee → swapPath)
  AaveV3Strategy / CompoundV3Strategy / VenusStrategy
    (bytes swapPath, uint256 minOut)
  MorphoStrategy
    (address rewardToken, uint256 claimable, bytes32[] proof,
     bytes swapPath, uint256 minOut)
  FluidStrategy
    (uint256 cumulativeAmount, uint8 positionType, bytes32 positionId,
     uint256 cycle, bytes32[] merkleProof, bytes metadata,
     bytes swapPath, uint256 minOut)

mocks/MockRewardDistributors.sol
  + MockRewardToken / MockCometRewards / MockVenusComptroller /
    MockAaveRewardsController / MockUniversalRewardsDistributor /
    MockFluidMerkleDistributor / MockSwapRouter
  Unit test distributor stand-in.

hardhat.config.ts
  viaIR: false → true. FluidStrategy.claimAndCompound 의 deeper local-variable
  count (swapPath 추가 + 6 distributor 인자) 에 stack-too-deep 회피.

V2.1.0 으로 배포된 vault 는 함수 시그니쳐 변경으로 호출 불가 → 폐기.
v2.1.1 새 배포 사이클 별도.

Refs: Soken APY-2026-06-001 §F-04 follow-up
…04 evidence

Strategy.claim.fork.spec.ts (Ethereum fork)
  - test_compound_claimAndCompound_revertsWhenNotKeeper
  - test_compound_claimAndCompound_zeroBeforeYieldAccrues
  - test_compound_claimAndCompound_claimsSwapsAndReinvests
    multi-hop COMP → WETH → USDC (UniV3 SwapRouter02) e2e.
    Fresh-fork distributor 가 dry 인 경우 whale 으로 top-up.

Strategy.claim.spec.ts (mock distributor unit)
  Compound (3 — claim, NotKeeper, InvalidPath)
  Venus (2)
  Aave  (2)
  Morpho (2 — mock URD)
  Fluid  (2 — mock distributor with msg.sender check)

Strategy.claim.bsc.fork.spec.ts (skipped on chain mismatch)
  hardhat 의 chain-56 hardfork-history 매칭 issue 로 BSC fork 미사용.
  Compound real fork 가 BaseStrategy._swapAndReinvest 의 multi-hop path 를
  공유 검증 + 4 mock 이 distributor 호출 path 검증.

Test
  npx hardhat test                                              # 103 passing
  FORK=true npx hardhat test test/v2/Strategy.claim.fork.spec.ts  # 3 passing

Refs: Soken APY-2026-06-001 §F-04 follow-up evidence
V2.1.0 의 F-04 fix 가 single-hop UniV3 swap (exactInputSingle) 만 지원해서
COMP / MORPHO 같은 reward 토큰의 direct USDC pool 유동성 부족으로 mainnet
revert 되는 issue 를 V2.1.1 multi-hop path 로 fix 한 follow-up 섹션 추가.

§F-04 아래 새 subsection: "F-04 follow-up — multi-hop swap path (V2.1.1)"
  - rationale (mainnet probe 결과)
  - 코드 변경 4 항목 (_swapAndReinvest 시그니쳐, _validateSwapPath, 5
    strategy claimAndCompound, viaIR)
  - test coverage (Compound real fork 3 + mock 11 = 14 cases)
  - coverage rationale (BaseStrategy shared path → Compound 가 representative
    e2e witness)

Refs: Soken APY-2026-06-001 §F-04 follow-up
@kimandy7778 kimandy7778 merged commit f254b40 into main Jun 25, 2026
@kimandy7778 kimandy7778 deleted the feat/v2.1.1-multihop branch June 25, 2026 06:27
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