Architecture
Overview

Architecture

The UniStaker system is designed with simplicity and security as its primary goals. It optimizes for these properties.

The system has two core components, the UniStaker contract and the V3FactoryOwner contract. The system is designed to interoperate with existing onchain infrastructure, including Uniswap V3 and the Uniswap Governance contracts.

Components

UniStaker

The core component of the system is the UniStaker contract implemented in UniStaker.sol. It manages the distribution of rewards to stakers and the delegation of their governance voting weight. It also allows stakers to designate a beneficiary address, that is, the address that will accrue the rewards distributed.

The UniStaker contract does not collect rewards. Instead, it outsources the collection of rewards to "rewards notifier" contracts which must be whitelisted by the UniStaker contract's admin role. This role is intended to be held by Uniswap Governance.

V3FactoryOwner

The first source of rewards being proposed are protocol fees from Uniswap V3 Pools. These fees are currently not active on any pools. The right to turn these fees on is controlled by the owner role of the UniswapV3Factory (opens in a new tab) contract. That role is currently held by Uniswap Governance, specifically by the governance timelock contract.

The V3FactoryOwner contract implemented in V3FactoryOwner.sol is intended to replace the timelock contract as the owner of the V3 Factory. For this to occur, Uniswap Governance must pass a governance proposal that transfers the ownership, while enshrining itself as the admin of the new V3FactoryOwner instance.

Composition

The components of the system interact with each other, and with the other contracts onchain, across simple abstraction boundaries. Each component assumes as little as possible about other parts of the system.

This section describes the system's intended design. The system has not yet been deployed or adopted by Uniswap Governance.

Here we describe the relationships depicted in the diagram above:

  • UNI token holders stake tokens and delegate their governance voting weight in the UniStaker contract.
  • Uniswap Governance is the admin of the V3FactoryOwner contract.
  • The V3FactoryOwner contract is the owner of the UniswapV3Factory.
  • The V3FactoryOwner contract has passthrough methods which allow it set protocol fees on Uniswap V3 Pools. Only Uniswap Governance can call these methods.
  • The V3FactoryOwner allows external parties to profitably collect fees from pools by calling the claimFees method. In exchange, they must provide a fixed amount of the reward token.
  • Rewards are immediately transferred to the UniStaker contract.
  • The V3FactoryOwner contract is a whitelisted rewardNotifier in the UniStaker contract.
  • The V3FactoryOwner notifies the UniStaker contract when it receives a reward from an external party.
  • UNI stakers earn and claim rewards from the UniStaker contract.