Skip to content

Conversation

@Debugger022
Copy link
Contributor

@Debugger022 Debugger022 commented Jan 21, 2026

Summary

This PR adds VIP-600: SwapRouter Implementation on BNB Chain (testnet + mainnet).

The VIP accepts ownership of the deployed SwapRouter contract via acceptOwnership(),
transferring control to the Venus Protocol Normal Timelock.

Mainnet: 0xde7E4f67Af577F29e5F3B995f9e67FD425F73621
Testnet: 0xd3F226acA3210990DBA3f410b74E36b08F31FCf2

What's included

VIP proposal — Single governance action calling acceptOwnership() on the SwapRouter
contract.

Simulation coverage:

Category Tests
Token swaps swapAndSupply, swapAndRepay, swapAndRepayFull
Native BNB swaps swapNativeAndSupply, swapNativeAndRepay, swapNativeAndRepayFull
Admin functions sweepToken, sweepNative (owner-only token/BNB recovery)
Ownership Two-step transfer verification (transfer → accept → restore)
Error handling MarketNotListed, ZeroAmount, ZeroAddress, SwapFailed, UnauthorizedNativeSender
Integration Full user journey: supply → borrow → partial repay via router

Swap calldata strategy: API-first (Venus swap API, 20s timeout) with PancakeSwap V2 on-chain
fallback. Uses deterministic EIP-712 signed multicall via SwapHelper for reproducible fork
tests.

Test plan

npx hardhat test simulations/vip-600/bscmainnet.ts --fork bscmainnet                                 
npx hardhat test simulations/vip-600/bsctestnet.ts --fork bsctestnet                                 
  • Ownership accepted — owner is Normal Timelock, pendingOwner is zero address
  • All swap operations emit correct events (SwapAndSupply, SwapAndRepay)
  • Revert cases trigger expected custom errors
  • Integration cycle completes end-to-end
  • sweepToken / sweepNative restricted to owner

@Debugger022 Debugger022 self-assigned this Jan 21, 2026
Debugger022 and others added 4 commits January 27, 2026 13:10
…a in vip-581 addendum2

Use deterministic EIP-712 signer for SwapHelper multicall instead of
fetching live swap quotes from the Venus API, making tests reproducible
on forked chains without external dependencies.
fred-venus
fred-venus previously approved these changes Jan 27, 2026
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very detailed test ~

…dum2

Replace USDC with U token as collateral in cross-asset leverage tests
(enterLeverage, exitLeverage, enterLeverageFromBorrow) since the VIP
enables flash loans on vU. Update U_HOLDER to a whale with sufficient
balance at the fork block and remove unused USDC references.
…p strategy and parallel execution

  - Add Venus swap API integration (20s timeout, single retry on quick failures)
    with PancakeSwap V2 fallback for swap calldata building
  - Parallelize independent RPC calls using Promise.all for balance reads,
    signer initialization, and view function queries
  - Fix nonce conflicts by keeping same-signer transactions sequential
    (oracle configs, revert assertions, token transfers)
  - Add results tracker with summary table printed after all tests
  - Extract reusable parseEvents helper to reduce event parsing boilerplate
  - Fix enterLeverageFromBorrow: add missing USDT approval for
    LeverageStrategiesManager before entering leverage from borrow
  - Remove verbose JSDoc comments in favor of self-documenting code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants