Code Monkey home page Code Monkey logo

0x-api-simbot's Introduction

0x-api-simbot

Perform loads of swaps against the live 0x-api swap/quote endpoint. Requires geth eth_call support (which Infura apparently has now).

Running

Single source sims:

NODE_RPC=YOUR_GETH_RPC_URL yarn start {--url SWAP_QUOTE_URL} [--output SWAPS_OUTPUT_FILE.json] {--token SYMBOL}  [--buys]  [--sells] [--v0] [--jobs NUM_CONCURRENT_REQUESTS]

Multi-source (A-B) sims:

NODE_RPC=YOUR_GETH_RPC_URL yarn start-ab {--url SWAP_QUOTE_URL} [--output SWAPS_OUTPUT_FILE.json] {--token SYMBOL} [--buys]  [--sells] [--v0] [--jobs NUM_CONCURRENT_REQUESTS]

Command Line Options

option description
--url -u URL The swap-quote API url. Can be repeated for ex: https://api.0x.org/swap/v0/quote.
--output -o FILE JSON file to append sim data to. The python analytics tools can parse this file.
--token -t TOKEN Tokens to include in the simulations. Can be repeated. Defaults are WETH, DAI, USDC.
--jobs -j N Number of concurrent requests to make. Default is 1, which is very slow.
--buys Whether to only do buy swaps. Default is both.
--sells Whether to only do sells swaps. Default is both.
--v0 Whether to run in v0 (non-Exchange Proxy) compat mode. This will prevent swaps to ETH.

Analytics

There are a bunch of analysis scripts in the /py folder. Just run them directly, passing the swap output file in.

Configuration

The first time simbot is run (through start or start-ab) a config.json file will be created in the root. You can configure certain addresses and contract overrides from this file.

Example:

{
    "erc20Proxy": "0x95e6f48254609a6ee006f7d493c8e5fb97094cef",
    "exchange": "0x61935cbdd02287b511119ddb11aeb42f1593b7ef",
    "forwarder": "0x6958f5e95332d93d21af0d7b9ca85b8212fee0a5",
    "taker": "0xd00d00caca000000000000000000000000001337",
    "gst": "0x0000000000b3F879cb30FE243b4Dfee438691c04",
    "transformers": {
        "deployer": "0x80a36559ab9a497fb658325ed771a584eb0f13da",
        // Transformers that have constructor-defined immutable state have to be
        // hot-redeployed so they must be declared by deployer nonce, not address.
        "overridesByNonce": {
            "3": {
                "artifactPath": "../0x-monorepo/contracts/zero-ex/test/generated-artifacts/FillQuoteTransformer.json",
                "constructorArgs": ["0x61935cbdd02287b511119ddb11aeb42f1593b7ef"], // optional
                "balance": 0 // optional
            }
        }
    },
    // Contracts without immutable state and share the same initialization code
    // can simply be overridden.
    "overrides": {
        "0x95e6f48254609a6ee006f7d493c8e5fb97094cef": {
            "artifactPath": "../0x-monorepo/contracts/asset-proxy/test/generated-artifacts/ERC20Proxy.json",
            "balance": 0, // optional
            "nonce": 1 // optional
        },
    },
    // Contracts to deploy just-in-time. These will be deployed in order of occurence by
    // `deployer`, starting with `initialNonce` nonce. You can use
    // `yarn deployed-address` to predict the address of the contract.
    "deployments": {
        "deployer": "0xdededededededededededededededededededede",
        "initialNonce": 0,
        "contracts": [
            {
                "artifactPath": "../0x-monorepo/contracts/exchange/test/generated-artifacts/Exchange.json",
                "constructorArgs": [1], // optional
                "value": 0 // optional
            }
        ]
    }
}

0x-api-simbot's People

Contributors

dekz avatar dorothy-zbornak avatar merklejerk avatar moodlezoup avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.