Git Product home page Git Product logo

zkbob-contracts's Introduction

BOB and zkBOB smart contracts

This repository contains all smart contracts that are being used in BOB and zkBOB projects. Please refer to https://docs.zkbob.com for up-to-date project information.

License

BOB and zkBOB smart contracts source code is released under the CC0-1.0 License. Some smart contracts that were adapted from their original versions developed by the ZeroPool team, are released under the MIT License.

zkbob-contracts's People

Contributors

akolotov avatar alexsaplin avatar k1rill-fedoseev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zkbob-contracts's Issues

USDC.e -> USDC migration

What to do?

Most of the top-tier exchanges already use native USDC as a default withdrawal option for Polygon. We asked Circle and Polygon directly about their plans regarding the expansion of the token and they told us they do this actively.

  1. Binance already uses it as a default option
  2. Coinbase started to use it as well
  3. Polygon said they are actively replacing this token with a native one for all platforms on the chain
  4. They already set Uniswap pool for 600k

We need to to plan to migrate the pool in the upcoming month because people who get UDSC from exchanges and most of other apps couldn't use it in zkBob

@akolotov @k1rill-fedoseev Could we use the same process that we used previously? How much time do we need for the preparation?

Send some gas tokens to the withdrawal address

User might be interested in getting some native gas tokens when withdrawing BOB tokens from shielded pool. So the user could pay some extra fee to relayer that would be automatically exchanged and transferred to the user as native gas token

Need to research and propose a user flow.

Changes to Pool contract

  • Contains a queue of pending transactions
  • Contains a list of pending nullifiers
  • change transact: it must append new tx commitment instead of new root
  • Contains a whitelist of provers
  • Is upgradeable ( need to fix storage slot collision)

Deposit support for Sequencer contract

  • Add one more permit fields set to memo
  • upfront fees for permitable deposts
  • Disseminate fees to proxy and prover when transaction is processed in Pool
  • #95
  • Support permittable deposit
  • #96

Restrict request and execute a recovery if the recovery is not enabled

Consider to check that the recovery is allowed by checking recoveredFundsReceiver in requestRecovery and executeRecovery

require(_accounts.length == _values.length, "Recovery: different lengths");
require(_accounts.length > 0, "Recovery: empty accounts");

require(executionTimestamp > 0, "Recovery: no active recovery request");
require(executionTimestamp <= block.timestamp, "Recovery: request still timelocked");

Upgrade scripts

  1. Deploy current contracts on Sepolia
  2. Make some transactions
  3. Run upgrade to decentralized relayer contracts version
  4. Checks that everything is fine on the client/relayer/contracts side

Introduce a fee recipient

Since fees are collected in BOB whereas the operator spends native tokens to pay for gas, expected flow to cover gas expenses will be:

  1. The operator withdraws BOB tokens by withdrawFee
  2. The operator swaps BOB tokens to native tokens

The operator is an account which the relayer sends transaction behalf of. The relayer does not have the functionality to call withdrawFee. If an admin will uses the operator's PK to call withdrawFee it could be not safe.

At the same time it is a good practice (it was implemented in POSDAO) to have two accounts for operators: one is to send service transactions, another is to receive rewards and expenses coverage.

Consider to keep a separate account as the fee recipient for every operator.

In this case the flow to cover expenses will be:

  1. The fee recipient withdraws BOB tokens by withdrawFee
  2. The fee recipient swaps BOB tokens to native tokens
  3. The fee recipient sends native tokens to the operator.

Operations limits

Limits

The main goal is to create an additional barrier for illicit activities and at the same time not to impair ability for regular users. Since the main feature to distinguish illicit transaction right now is the amount, it's seems reasonable to set following restictions:

  1. A single operation ( deposit or withdrawal ) cannot exceed A
  2. A single address must not deposit more than B during a single period of 24 hours
  3. Overall sum of all of the deposits during a single period of 24 hours must not exceed C
  4. Overall amount of tokens in the Pool must not exceed D

Implementation

  1. Add a mutable daily quota value to the Pool state and constructor
  2. Add a map of all the addresses that have transacted that day and additional counters for overall deposits and
  3. When a user performs a transaction check that
    1. map entry doesn't exist or contains enough quota
    2. this operation doesn't result in any excess in cumulative metrics (all daily deposits, pool overall value)
  4. Process transaction
  5. Reduce the quota

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.