Giter VIP home page Giter VIP logo

shared-fund's Introduction

Shared Fund

Create or join a crypto investment portfolio with constant proportions that is balancing when the market moves.

Your share in a Portfolio is represented as a NFT that can be transfer. You can claim your share back at any moment.

The Portfolio is rebalanced using Chainlink to determine the moment and Uniswap to execute the swap.

Specification

sequenceDiagram
    actor Owner
    participant Contract
    Note over Owner : Initialize Portfolio
    Owner ->> Contract : deploy()
    Note over Owner : Auto invite to the Portfolio  
    Owner ->> Contract : invite()
    Note over Owner : Add ETH to the Portfolio
    Owner ->> Contract : deposit()
    Note over Owner : Add WBTC to the Portfolio
    Owner ->> Contract : add_asset(token_address, proportion)
    Note over Owner : Change assets proportions
    Owner ->> Contract : change_proportions(token_address, proportion)
    Note over Owner : Rebalance to the Portfolio
    Owner ->> Contract : rebalance()
    loop Rebalance each token
        Contract ->> Chainlink : get_token_price()
        Chainlink ->> Contract : token_price
        Contract ->> Uniswap : swap_token()
    end
    Note over Owner : Invite new Owner to the Portfolio
    Owner ->> Contract : invite()
    Note over Owner : Withdraw from the Portfolio
    Owner ->> Contract : withdraw()
Loading

Design

Smart Contrcat

graph

Stack

  • Foundry / Anvil
  • WAGMI (React)
  • Chainlink
  • Uniswap
  • OpenZeppelin
  • Solidity

Quickstart

It is necessary to have installed Foundry to be able to build, test and deploy the project. After setting up foundry, use the following commands to setup, test and deploy the project:

make # setup the project
forge test # run the tests locally
make anvil-fork-mainnet # start a mainnet fork
# modify the .env file to add:
# - the private key (found the last output of previous command)
# - the mainnet rpc url (you can get one in alchemy.com)
make deploy-anvil # deploy the contract to the mainnet fork
cd app && yarn && yarn dev # start the app
# import the private key from anvil to your wallet
# open the app in http://localhost:3000
# connect your wallet and start using the app
# change the network of your wallet to localhost:8545
# change the chainId of the localnet on metamask to 1
# copy your public address and invite yourself
# using the "Invite New Owner" button in "/fund" 

shared-fund's People

Contributors

patriciobcs avatar enitrat avatar louistricotkarl avatar

Watchers

 avatar

shared-fund's Issues

Build a initial portfolio

To demonstrate the usage of Chainlink Price Feeds it is necessary to create a simple portfolio where an user can add assets and get the total value of its portfolio using Chainlink.

Integrate the frontend with the smart contract using wagmi/ethers

The frontend needs some refactoring in the UI, and the integration of wagmi/ethers to interact with the smart contract.

Tasks:

  • Add wagmi wallet connect
  • Refactor UI and improve styles
  • Add transaction component and demostrate how to call the smart contract
  • Add changeAssets method that can remove, add or modify any asset in base to what user wants.
  • Add getAssets view function to smart contract to get all the assets in a good format.
  • Replace the fund simulations by two hooks useFund and useAssets (the latter lives under the first one).
  • Add get owners feature to useFund.
  • Add invite owners feature to useFund.
  • Add UI for the NFT shares (transfer)
  • Add rebalance and change proportions of assets
  • Fix parsing of price, amount, etc.

Deploy to testnet

To be able to show the project to other people, it is possible to:

  • Deploy smart contracts to Goerli
  • Deploy app as a Github Page

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.