Ronin

An EVM blockchain crafted for developers building games with player-owned economies.

  • Start date16 Oct 2024
  • End date30 Oct 2024
  • Total awards$50,000 in USDC
  • Duration14 days

Ronin audit details

  • Total Prize Pool: $50,000 in USDC
    • HM awards: $39,800 in USDC
    • QA awards: $1,700 in USDC
    • Judge awards: $4,800 in USDC
    • Scout awards: $500 in USDC
  • Read our guidelines for more details
  • Starts October 16, 2024 20:00 UTC
  • Ends October 30, 2024 20:00 UTC

Automated Findings / Publicly Known Issues

The 4naly3er report can be found here.
The Slither outputs can be found here and here

Note for C4 wardens: Anything included in this Automated Findings / Publicly Known Issues section is considered a publicly known issue and is ineligible for awards.

  • Centralization risk. Sky Mavis is responsible for maintaining the Katana V3 contracts and will able to upgrade the contract if necessary, as well as specify additional fee tiers.
  • All public known issues, including public audit reports of Uniswap V3 that affect Katana V3
  • If a liquidity pool (pair of tokens) is already open for liquidity provision on Katana V2, liquidity providers are expected to be able to migrate their liquidity to the corresponding pool on Katana V3 when it is created, without being restricted by the authorization function of the Governance.

Overview

Katana v3 is a decentralized exchange (DEX) protocol built on the foundations of Uniswap V3. It retains core features like concentrated liquidity, protocol fees, and the integrated price oracle mechanism. However, Katana v3 introduces key modifications to better align with specific project objectives.

Key Changes from Uniswap V3

  • Customizable Protocol Fee Tiers: Katana v3 allows for flexible fee structures with multiple protocol fee tiers, improving adaptability across different market conditions and asset types.
  • Authorized Protocol Actions: Certain actions within the protocol are managed more systematically through authorization, improving operational integrity and efficiency.
  • Feature Simplification: Unused features from Uniswap V3, such as NFT trading and protocol fee collection, were removed to streamline functionality and reduce complexity.

Links


Scope

Files in scope

Filecode
katana-v3-contracts/src/core/KatanaV3Pool.sol566
katana-v3-contracts/src/periphery/NonfungiblePositionManager.sol320
katana-operation-contracts/src/governance/KatanaGovernance.sol227
katana-operation-contracts/src/aggregate-router/base/Dispatcher.sol176
katana-v3-contracts/src/periphery/lens/MixedRouteQuoterV1.sol150
katana-operation-contracts/src/aggregate-router/modules/katana/v3/V3SwapRouter.sol126
katana-v3-contracts/src/periphery/NonfungibleTokenPositionDescriptor.sol91
katana-v3-contracts/src/periphery/V3Migrator.sol85
katana-v3-contracts/src/core/KatanaV3Factory.sol77
katana-operation-contracts/src/aggregate-router/modules/Payments.sol73
katana-operation-contracts/src/aggregate-router/modules/katana/v2/V2SwapRouter.sol71
katana-v3-contracts/src/periphery/libraries/KatanaV2Library.sol71
katana-v3-contracts/src/periphery/libraries/KatanaV2LibraryTestnet.sol71
katana-operation-contracts/src/aggregate-router/AggregateRouter.sol49
katana-v3-contracts/src/core/interfaces/pool/IKatanaV3PoolEvents.sol49
katana-v3-contracts/src/core/interfaces/pool/IKatanaV3PoolState.sol47
katana-v3-contracts/src/periphery/interfaces/IKatanaV2Pair.sol44
katana-v3-contracts/src/external/interfaces/IKatanaGovernance.sol43
katana-v3-contracts/src/periphery/interfaces/IMixedRouteQuoterV1.sol28
katana-v3-contracts/src/periphery/base/PoolInitializer.sol27
katana-v3-contracts/src/periphery/libraries/PoolAddress.sol26
katana-v3-contracts/src/core/KatanaV3PoolDeployer.sol25
katana-operation-contracts/src/aggregate-router/modules/katana/KatanaImmutables.sol22
katana-operation-contracts/src/aggregate-router/libraries/Commands.sol20
katana-v3-contracts/src/core/interfaces/IKatanaV3Factory.sol19
katana-operation-contracts/src/governance/interfaces/IKatanaV2Factory.sol16
katana-v3-contracts/src/core/KatanaV3PoolProxy.sol16
katana-operation-contracts/src/aggregate-router/modules/PaymentsImmutables.sol15
katana-v3-contracts/src/core/interfaces/IKatanaV3Pool.sol13
katana-v3-contracts/src/core/interfaces/pool/IKatanaV3PoolImmutables.sol13
katana-v3-contracts/src/periphery/base/PeripheryImmutableState.sol13
katana-operation-contracts/src/aggregate-router/base/RouterImmutables.sol10
katana-v3-contracts/src/external/libraries/AuthorizationLib.sol10
katana-v3-contracts/src/core/KatanaV3PoolBeacon.sol9
katana-v3-contracts/src/core/interfaces/IKatanaV3PoolDeployer.sol8
katana-v3-contracts/src/periphery/interfaces/IPeripheryImmutableState.sol6
katana-v3-contracts/src/core/interfaces/IKatanaV3PoolBeaconImmutables.sol5
SUM:2637

If you discover a bug in any contract or library outside of the files listed above that impact following contracts, we will consider the issue valid:

  • KatanaGovernance
  • AggregateRouter
  • KatanaV3Factory
  • NonfungiblePositionManager
  • V3Migrator
  • KatanaV3PoolBeacon
  • KatanaV3Pool

KatanaGovernance, KatanaV3Factory, NonfungiblePositionManager contracts are deployed with transparent proxy.

All vulnerabilities in the KatanaGovernance contract that do not affect user funds will have their severity downgraded by one level.

Priority files

katana-v3-contracts:

src/core/KatanaV3PoolProxy.sol
src/core/KatanaV3Pool.sol
src/core/KatanaV3Factory.sol
src/periphery/NonfungiblePositionManager.sol
src/periphery/V3Migrator.sol

katana-operation-contracts:

src/aggregate-router/AggregateRouter.sol
src/aggregate-router/modules/katana/v2/V2SwapRouter.sol
src/aggregate-router/modules/katana/v3/V3SwapRouter.sol

Files out of scope

These files are explicitly out of scope:

katana-v3-contracts/src/periphery/SwapRouter.sol
katana-v3-contracts/src/periphery/examples/PairFlash.sol
katana-v3-contracts/src/periphery/libraries/KatanaV2LibraryTestnet.sol
katana-v3-contracts/src/periphery/lens/MixedRouteQuoterV1Testnet.sol

Scoping Q & A

General questions

QuestionAnswer
ERC20 used by the protocolAny (all possible ERC20s)
ERC721 used by the protocolN/A
ERC777 used by the protocolN/A
ERC1155 used by the protocolN/A
Chains the protocol will be deployed onRonin

ERC20 token behaviors in scope

External integrations (e.g., Uniswap) behavior in scope

QuestionAnswer
Enabling/disabling fees (e.g. Blur disables/enables fees)Yes
Pausability (e.g. Uniswap pool gets paused)Yes
Upgradeability (e.g. Uniswap gets upgraded)Yes

EIP compliance checklist

N/A

Additional context

Main invariants

  • User can remove their provided liquidity
  • Only owner can add fee tier as well as enable flash loan feature
  • Protocol fees will be directly transferred to the treasury without fee-collecting operations needed

Attack ideas (where to focus for bugs)

  • Funds blocking
  • Stealing of funds
  • Protocol insolvency
  • Fee distribution logic
  • Access control on pool contract
  • Contract upgradability patterns

All trusted roles in the protocol

Role
Proxy Admin
Governance Owner
Beacon Owner
Factory Owner (i.e. the Governance contract)

Describe any novel or unique curve logic or mathematical models implemented in the contracts

N/A

Assumptions

As Uniswap V3, Katana V3 was developed with the following assumptions, and thus any bug must also adhere to the following assumptions to be valid:

  • The total supply of any token does not exceed 2<sup>128</sup> - 1, i.e. type(uint128).max.
  • The transfer and transferFrom methods of any token strictly decrease the balance of the token sender by the transfer amount and increases the balance of token recipient by the transfer amount, i.e. fee on transfer tokens are excluded.
  • The token balance of an address can only change due to a call to transfer by the sender or transferFrom by an approved address, i.e. rebase tokens and interest bearing tokens are excluded.
  • If a liquidity pool (pair of tokens) is already open for liquidity provision on Katana V2, liquidity providers are expected to be able to migrate their liquidity to the corresponding pool on Katana V3 when it is created, without being restricted by the authorization function of the Governance.

Testnet deploy

All contracts are deployed on Saigon testnet. Note that these on-chain contracts are provided for testing purpose and not considered as in-scope assets.

Running tests

katana-v3-contracts:

git clone https://github.com/ronin-chain/katana-v3-contracts --recurse
cd katana-v3-contracts && git checkout release/v1.0.0
forge build

katana-operation-contracts:

git clone https://github.com/ronin-chain/katana-operation-contracts --recurse
cd katana-operation-contracts && git checkout release/v1.0.0
forge build

Miscellaneous

Employees of Sky Mavis / Ronin and employees' family members are ineligible to participate in this audit.

Code4rena's rules cannot be overridden by the contents of this README. In case of doubt, please check with C4 staff.