Git Product home page Git Product logo

zeneth's Introduction

Zeneth Logo

Gasless Ethereum account abstraction with Flashbots.

🚀 zeneth.app 🚧 @ScopeLift

Ethereum Badge

About

With Flashbots, users can send transactions directly to miners so their transactions may be included in a block without ever being seen in the mempool. Miners typically include your transaction in a block because they earn revenue from gas fees, but with flashbots you can include transactions with a gas price of zero, as long as you also include a transaction that pays the miner in ETH in some way.

This is commonly used to protect yourself from bots. For example, by making a large Uniswap trade or executing an arbitrage via Flashbots, bots cannot see your transaction and frontrun it.

Zeneth uses Flashbots for a different reason—improving UX.

A major UX problem in Ethereum is that most wallets are not contract wallets, but externally owned accounts (EOAs), such as MetaMask. With EOAs, you always need ETH for gas unless you happen to be interacting with a contract that supports meta-transactions. This can be problematic for user-facing applications as their new users need to acquire both ETH and often some token to user their application.

For example, you don't need ETH for transaction fees on zkSync's Layer 2 network, but if I'm a new user trying to get DAI into zkSync, I need to first find ETH, use that to pay for gas to enter zkSync, then never use that ETH again. This adds a lot of friction to user onboarding.

Zeneth fixes this. You can now bundle any sequence of transactions, send them for zero gas, and at the end use our "SwapBriber" contract which will swap some of your tokens for ETH to pay the miner. In the demo video you can see the following sequence of transactions:

  1. User signs a zero-gas price transaction approving the zkSync contract to spend their DAI
  2. User signs a zero-gas price transaction depositing their DAI into zkSync
  3. User signs a zero-gas price transaction approving the SwapBriber contract to spend their DAI
  4. User signs a zero-gas price transaction transferring tokens to the SwapBriber contract, which swaps those tokens for ETH and transfers the ETH to the miner

Then, all four of these transactions are sent as a bundle to the miner, who includes them in a block.

Status

Zeneth was built for the ETHGlobal hackathon. You can learn more by watching the hackathon submission video.

The project works on mainnet, but is not currently deployed for public use. Stay tuned to learn more about Zeneth's public launch.

Development

This project is a monorepo with three packages:

  • contracts contains the smart contracts
  • zeneth-js is a TypeScript library containing the core Zeneth logic
  • frontend is a simple frontend app for interacting with Flashbots

Dependencies

To ensure that everyone is using the same version of nodejs on this project, volta is recommended!

Develop

yarn
yarn dev

Test

yarn test

Serve

yarn build
yarn start

zeneth's People

Contributors

apbendi avatar jferas avatar mds1 avatar wildmolasses 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  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

zeneth's Issues

Bundle Status Post Submission

Technical

  • Option 1: Look into websockets from server --> Flashbots and server --> frontend
  • Option 2: Submit one block at a time through relayer so it is unlikely to timeout

Also: ask Flashbots team about enabling CORS or whitelisting Zeneth

UX / Frontend

  • Show pending bundle indicator
  • Counter for the valid blocks remaining
  • What to show if it fails? --> Simple error message. Content? --> "Your transactions was not included by miners. Please try again."

Make SwapBriber Sweepable

The SwapBriber accrues ETH profits via trades. A privileged account needs the ability to withdraw these.

Mega Issue: Zeneth Next Step Prioritization

  • Small UX improvements
  • Devops Improvements (get auto deploys working)
  • Adding more tokens to list that can be transferred
  • Debugging the MetaMask-doesn't-pop-up issue
  • Getting L2 Entry working + adding L2s
  • Moving some functionality to the backend
    • Bundle signing
    • Managing token list
    • Bundle submission
  • Custom RPC Backend Approach
  • Getting other DeFi functions working
    • DEX Swaps
    • Deposit/withdrawal to yield protocols (Compound, AAVE, Yearn, etc..)
    • Other? (What DeFi actions are especially subject to front running / sandwich attacks?)
  • Preparing for EIP-1559
  • RPC + Browser extension approach

Hackathon Finals UI Polish

  • Add Logo and header
  • Add cleaner colors/branding/styles
  • Add homescreen with options/buttons and separate form screens for:
    • Gasless L2 Entry
    • Gassless token transfer
  • Cleanup entry forms; use regular numbers instead of raw decimals
  • Show various L2's in drop down selection for gasless L2 Entry, bonus: show logos
  • ...?

Show Truncated Address In Header Status

In the header status widget, rather than showing the full connected address, show first four, "...", and last four. For example:

0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 would appear as 0xd8d...6045

Hovering over the truncated address should show a tooltip with the full address text.

Zeneth Public MVP Spec

Hard requirements for the absolute MVP to get to mainnet:

  • Top Line Features:
    • Gasless token transfer
      • High liquidity / quality token list (Uniswap default token list?)
      • Arbitrary tokens ✂️
    • Gasless L2 Entry ✂️
      • zkSync
      • Any other L2 ✂️
  • Usability features
    • Proper fee estimation - This requires figuring out how much gas the user action will take, adding some padding for profit, then using this to inform the swap params in the final bundle tx
    • Show the user the status of the transaction bundle after submission - Rather than using the promises from the flashbots SDK, figure out what the SDK is doing under the hood, and mimic that in an endpoint in our backend, then poll that endpoint
    • Switch to Uniswap v3?
  • UI Polish
    • Background colors
    • Cleanup wallet section of header
    • Cleanup project name/logo section of header
  • Dev considerations
    • Upgrade to the latest Flashbots version
    • Frontend deployment
    • DNS configuration
  • Legal/administrative considerations
    • Add Privacy policy & terms of service
    • Beta warning

Import JSON files with TypeScript Properties

Attempts to import contract artifacts using...

import * as UniswapV2FactoryArtifact from '@uniswap/v2-core/build/UniswapV2Factory.json';
import * as UniswapV2Router02Artifact from '@uniswap/v2-periphery/build/UniswapV2Router02.json';

...fails with the following error...

Cannot find module '@uniswap/v2-core/build/UniswapV2Factory.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.ts(2732)

Token Transfer Contract Spec

Using a contract will allow us to make the tx atomic, which should provide a bit of protection from uncle leak attacks of any kind.

Possible function signature:

function transferAndBribe(address _token, uint256 _tokenAmount, address _receiver, uint256 _ethBribe);

Possible function state vars:

  • uint256 fee
  • address owner

Function logic:

  • Perform transferFrom of _tokenAmount of _token (implies pre-approval)
  • Swap tokens for exact eth amount _ethBribe + fee (via uniswap v2 router)
  • transfer amount of fee to owner
  • transfer amount of _ethBribe to coinbase
  • ERC20 transfer remaining tokens to _receiver

Overall this would only need 2 txs, right?

  1. Approval
  2. transferAndBribe function call

Other thoughts/questions

  • Presumably owner should be able to update fee
  • OR should fee somehow be dynamic, calculated as percentage of send, etc...?
  • Can the function find the uniswap path internally, or assume/calculate a token/ETH pair, or does the path for the swap also need to be part of the function signature?
  • Any other approaches that might be more gas efficient?
  • Any security concerns, loss of fund risks? Rebasing tokens? Etcc..?

0 gas price txs no longer accepted after eip-1559 in relayer.test

Im trying to run the relayer.test.ts file but im getting error 0 gas price txs no longer accepted after eip-1559

  const tx1 = {
            chainId,
            data: transferData,
            from: user.address,
            gasLimit: BigNumber.from('250000'),
            gasPrice: Zero,
            nonce,
            to: dai.address,
            value: Zero,
   };

Add Info About Miner Incentive Multiplier

Next to "Miner Incentive Multiplier" add a little "Info Icon" (example here. When the user hovers over the (i), show a tooltip message that says: "The amount we'll multiply the prevailing market gas rate by when bribing the miner to incentivize them to include your transactions directly in the block."

Build errors

I am just playing around this project, further gas optimizations and flashbots. I am new with ethers-hardhat-typechain stack
While running npm build I am running into below type errors. Can you please suggest how to solve these issues

volta is installed

before building

volta pin [email protected]
node -v v14.16.1

tsc -v

Volta error: Could not locate executable tsc in your project.

Please ensure that all project dependencies are installed with npm install or yarn install

volta pin yarn

Build

yarn

yarn install v1.22.10 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] Resolving packages... [2/4] Fetching packages... info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning "workspace-aggregator-ab8edd8e-278f-40ee-9168-559e4c7ad63d > @scopelift/zeneth-js > @flashbots/[email protected]" has incorrect peer dependency "ethers@^5.1.4". warning "workspace-aggregator-ab8edd8e-278f-40ee-9168-559e4c7ad63d > @scopelift/zeneth-frontend > [email protected]" has incorrect peer dependency "ethers@^4". warning "workspace-aggregator-ab8edd8e-278f-40ee-9168-559e4c7ad63d > @scopelift/zeneth-frontend > [email protected]" has incorrect peer dependency "react@^16.8". warning "workspace-aggregator-ab8edd8e-278f-40ee-9168-559e4c7ad63d > @scopelift/zeneth-frontend > [email protected]" has incorrect peer dependency "react-dom@^16.8". warning "workspace-aggregator-ab8edd8e-278f-40ee-9168-559e4c7ad63d > @scopelift/zeneth-contracts > hardhat-gas-reporter > [email protected]" has unmet peer dependency "@codechecks/client@^0.1.0". warning "workspace-aggregator-ab8edd8e-278f-40ee-9168-559e4c7ad63d > @scopelift/zeneth-frontend > web3-react > @0x/subproviders > eth-lightwallet > [email protected]" has incorrect peer dependency "bitcore-lib@^0.16.0". [############################################################################################################################################################---------------------------------] 53463/64956^[4/4] Building fresh packages... [8/16] ⠈ keccak [-/16] ⠈ waiting... [-/16] ⠈ waiting... [15/16] ⠈ node-hid

$ husky install && lerna run prepare husky - Git hooks installed lerna notice cli v4.0.0 lerna info versioning independent lerna info Executing command in 1 package: "yarn run prepare" @scopelift/zeneth-js: yarn run v1.22.10 @scopelift/zeneth-js: $ yarn build @scopelift/zeneth-js: $ tsc --build @scopelift/zeneth-js: Done in 0.70s. lerna success run Ran npm script 'prepare' in 1 package in 1.1s: lerna success - @scopelift/zeneth-js Done in 226.56s.

tsc -v
Version 4.2.4

yarn build

yarn run v1.22.10 $ lerna run build lerna notice cli v4.0.0 lerna info versioning independent lerna info Executing command in 3 packages: "yarn run build" @scopelift/zeneth-contracts: $ hardhat compile @scopelift/zeneth-js: $ tsc --build @scopelift/zeneth-frontend: $ next build @scopelift/zeneth-frontend: info - Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5 @scopelift/zeneth-frontend: info - Checking validity of types... @scopelift/zeneth-contracts: Solidity 0.8.4 is not fully supported yet. You can still use Hardhat, but some features, like stack traces, might not work correctly. @scopelift/zeneth-contracts: Learn more at https://hardhat.org/reference/solidity-support" @scopelift/zeneth-contracts: Nothing to compile @scopelift/zeneth-frontend: Failed to compile. @scopelift/zeneth-frontend: ./src/components/Connection.tsx:37:28 @scopelift/zeneth-frontend: Type error: Binding element 'props' implicitly has an 'any' type. @scopelift/zeneth-frontend: 35 | } @scopelift/zeneth-frontend: 36 | @scopelift/zeneth-frontend: > 37 | const ConnectionModal = ({ props }) => { @scopelift/zeneth-frontend: | ^ @scopelift/zeneth-frontend: 38 | const { clearModal } = useContext(ModalContext); @scopelift/zeneth-frontend: 39 | const { connector, chainId, activate, deactivate, error } = useWeb3React<Web3Provider>(); @scopelift/zeneth-frontend: 40 | const { activatingConnector, setActivatingConnector, triedEager } = props; @scopelift/zeneth-contracts: Creating Typechain artifacts in directory typechain for target ethers-v5 @scopelift/zeneth-frontend: error Command failed with exit code 1. @scopelift/zeneth-frontend: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. lerna ERR! yarn run build exited 1 in '@scopelift/zeneth-frontend' lerna WARN complete Waiting for 1 child process to exit. CTRL-C to exit immediately. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Integrate Fee Estimation Into Front End

  • Update estimate fee method to return tuple that includes ETH bribe for miner
  • Update frontend to include profit-padding on the token fee from the estimate fee method (hardcoded 5% multiplier for now)
  • Display the padded token fee to the user in the interface (Cannot be edited)
  • Included padded token fee & original ETH bribe estimate as params to swapAndBribe call
  • Stretch requirement: let the user choose high/low fee setting, which adjusts the flashbots premium
  • Ensure token balance is sufficient after fee is included; show validation error or toast if it's not (example: user has 1000 DAI, tries to send 980, but fee is 40)

Fee Estimation

How to figure out gas that will be used by the transactions

  • Using the simulation
    • If the user has ETH, we can have the flashbots simulation tell us
    • If the user doesn't have ETH, the simulation will fail— could MEV geth change this?
    • Does the user have to sign the txs first? This makes for a weird UX, and also a problem in getting the amounts right before having the user sign
    • Also state related issue— what if user doesn't have token balance by final swapAndBribe, etc...
  • Estimate and hardcode for token transfers <--- probably MVP approach
    • Populating values for the initital token list
      • Look up a few approves, transfers, and swaps on Etherscan and eyeball it
      • Use Dune analytics query or etherscan API to pull values

Gas usage heuristic— how to figure out the gas price

  • Extremely naive option: multiply current gas price by 2 or 3
  • Other ideas: historical flashbots txs from API, last block tail gas, etc...
  • Ask Flashbots team for recommendations, likely to be impacted by bundle merging

User Experience

  • Once we have the gas estimate, show it in the selected token
  • Cannot be edited (?) (future— got higher but not lower?)
  • What happens if token balance is insufficient after fee is included? -- Toast or Form Validation on amount

Note: look into other solutions

UI Polish And Cleanup

  • Background colors
  • Cleanup wallet section of header
  • Cleanup project name/logo section of header

Support ENS In Frontend

  • In the wallet status widget: attempt ENS reverse resolution using the ethers.js reverse resolution functionality, and show the .eth name if one is returned instead of the full address. Show the address in a tooltip on hover.
  • On the transfer form: In the recipient field, allow the user to type an ENS name. When they exit the field, resolve the address and update the form to show it. If resolution fails, show an in line error

zeneth-js Test Failure

Getting the following simulation failure on main when running yarn test in zeneth-js:

Screen Shot 2021-06-30 at 10 44 05 PM

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.