GithubHelp home page GithubHelp logo

davidqw / tornado-relayer-registry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peppersec/tornado-relayer-registry

0.0 0.0 0.0 805 KB

Repository for a protocol upgrade which introduces a registry for relayers and staking mechanisms for the TORN token.

License: MIT License

Shell 0.10% JavaScript 64.46% Solidity 35.44%

tornado-relayer-registry's Introduction

Tornado Relayer Registry

Build Status Coverage Status

Repository for a governance upgrade which includes a registry for relayer registration and staking mechanisms for the torn token.

Overview

  1. Anyone can become a relayer by staking TORN into Registry contract.
  2. Minimum stake is governed by the Governance.
  3. Each Pool has its own fee % which is also set by the Governance.
  4. On every withdrawal via relayer, the relayer has to pay the Tornado Pool fee in TORN. The fee is deducted from his staked balance.
  5. All collected fees are stored into StakingReward contract.
  6. Any TORN holder can stake their TORN into Governance contract like they were before, but earning fees proportionately to their stake.

Caveats: Anyone can trigger price oracle update in order to adjust the calculation of how much TORN should be deducted. It uses Uniswap V3 TWAP oracle model.

Setup

git clone --recurse-submodules https://github.com/Tisamenus/tornado-relayer-registry.git
cd tornado-relayer-registry
yarn
cp .env.example .env
yarn test

Architecture

This will be a top-down look on the architecture.

RelayerRegistryProposal.sol

The governance proposal, which if executed by some party, should upgrade governance to a new version and initialize the data of all of the contracts which require data initalization outside of their construction scope.

This is for: 1. circular dependencies (one contract receives and address at construction while the other needs to register it if not being deployed by it) 2. community decided and other hardcoded parameters for regular contract functioning, 3. other necessary actions such as initializations for proxies.

This contract is not called directly and instead only the logic is used by a contract that calls it (governance). Thus, if delegatecalled, the calling contract communicates with:

  1. The Relayer Registry.
  2. The old Tornado Proxy.
  3. The new Tornado Proxy (TornadoProxyRegistryUpgrade).
  4. The Trees Contract.

RelayerRegistry.sol

This contract should store the data of each relayer, including their balance, which should be burned on withdrawals. It also stores any addresses the relayer decides to register under its own master address. When a withdrawal happens the contract decrements a relayers balance and calls the staking contract to increment the rewards.

Communicates with:

  1. The new Tornado Proxy.
  2. The Staking contract.
  3. The Governance contract.
  4. Relayers and user accounts.

TornadoProxyRegistryUpgrade.sol

This contract should upgrade the Tornado Proxy to include the following functionalities:

  • Updating rewards for individual stakers on lock and unlock.
  • Storing and updating the fee balance of relayers registered in the relayer registry.
  • Starting the burn procedure on relayer withdrawal.
  • All legacy proxy functionality.

Communicates with:

  1. The Relayer Registry.
  2. The Governance contract.
  3. The Pool Fee Calculator.
  4. Relayers and user accounts

PoolFeeCalculator.sol

This is an upgradeable contract which should calculate the correct fee for tornado pool withdrawals. This is contract will be deployed behind a proxy thus making logic upgradeable.

Communicates with:

  1. The new Tornado Proxy.

TornadoStakingRewards.sol

This contract should store relayer-staked torn and distribute it (update rewards) to accounts which have locked torn in governance. Each time a relayer withdraws, the amount of torn burned is added as rewards according to the SNX logic. Any account can then withdraw.

Communicates with:

  1. The Relayer Registry.
  2. The Governance Contract;
  3. User accounts.

tornado-relayer-registry's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.