Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.2 #59

Merged
merged 1 commit into from
Nov 26, 2023
Merged

v0.2 #59

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,971 changes: 265 additions & 2,706 deletions Cargo.lock

Large diffs are not rendered by default.

50 changes: 7 additions & 43 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
[package]
name = "mfm"
version = "0.1.29"
edition = "2021"
[workspace]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
resolver = "2"

[dependencies]
clap = { version = "4.0", features = ["derive", "cargo"] }
serde_yaml = "0.9"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
rustc-hex = "2.1"
tokio = { version = "1.0", features = ["full"] }
# TODO: upgrade and use as: https://github.com/graphprotocol/solidity-bindgen/blob/master/solidity-bindgen/src/secrets.rs
secp256k1 = "0.21.3" # this version is a dependency for web3
web3 = { version = "0.18.0" }
futures = "0.3.21"
prettytable-rs = "0.10"
once_cell = "1.10.0"
phf = { version = "0.11", default-features = false }
rpassword = "7.0"
# TODO: review the use of this lib to encryption, https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
magic-crypt = "3.1.10"
reqwest = "0.11.11"
tracing = { version = "0.1", features = [ "log" ] }
tracing-subscriber = { version = "0.3", features = [ "registry", "env-filter" ] }
tracing-bunyan-formatter = "0.3"
tracing-log = "0.1"
anyhow = { version = "1.0", default-features = false }
hex = "0.4.3"
thiserror = "1.0.33"
bigdecimal = { version = "0.3.0", features = ["serde"] }
num-bigint = { version = "0.4.3", features = ["serde"] }
num-traits = "0.2.15"
zeroize = "1.5.7"
orion = "0.17.2"
chrono = "0.4.23"
teloxide = "0.12.2"



[build-dependencies]
phf_codegen = "0.11.1"
walkdir = "2"
members = [
"mfm_cli",
"mfm_machine",
"mfm_machine_derive",
]
145 changes: 1 addition & 144 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,153 +1,10 @@
# MFM


**WARNING: this v0.1.x is not being in development anymore due to an [in-progress full refactor for a v0.2](https://github.com/willyrgf/mfm/pull/59)**

---


MFM (Multiverse Finance Machine) is a CLI to managing portfolio of cryptoassets directly in Blockchain using DEXs.

> **WARNING**: This project is in an alpha stage. It has not been audited and may contain bugs and security flaws. This implementation is NOT ready for production use.

## Big features coming
- [ ] Support LP's as a asset type and handle with them in the portfolio
- [ ] Support Yield Farms and Harvest rewards
- [ ] Add machine command within a module using state-machine logic to run sequencially and conditionally multiples commands as workflows
- [ ] Add automatic hedge using levarage derivatives (futures/options)
- [ ] Trading strategies with TA (in [mfm_server](https://github.com/willyrgf/mfm_server)?) to adjust dynamic portfolio positions

## Install via Nix profile
```sh
nix profile install github:willyrgf/mfm
```

## Local install & update using releases

### *nix (?)
```sh
# may need adjust for some systems
LATEST_APP_URL="$( \
curl -s https://api.github.com/repos/willyrgf/mfm/releases/latest |
grep 'browser_download_url' |
grep "$(uname | tr '[[:upper:]]' '[[:lower:]]')" |
awk -F '"' '!/.sha256sum/ {print $4}' \
)"
curl -s -L $LATEST_APP_URL -O
unzip -qo ${LATEST_APP_URL##*/}
```

## res/ directory
This directory will carry all the abi files used as default in this project.
All these abi files in this directory will be add in the binary in compilation time (`build.rs`).

To access this files we've a `shared::resources` module that will always condering your currently
filesystem `res/` directory and the default `static RES` compiled in the binary (`build.rs`),
following this order of priority respectively.

## Local test environment

### run GETH server
```sh
docker build -t geth_local tests/blockchains/gethnet
docker run --name geth_local -d -p 8545:8545 -p 8546:8546 geth_local
```

### stop & drop GETH server
```sh
docker stop geth_local && docker rm geth_local
```

### extract base wallet private key
```sh
$ ethkey inspect --private --passwordfile tests/blockchains/gethnet/password.txt tests/blockchains/gethnet/data/keystore/UTC--2023-03-28T01-13-34.803419000Z--4e22e05c29a7165aeee0d813be03af17f129a2d1
Address: 0x4E22e05C29A7165Aeee0D813bE03Af17F129A2d1
Public key: 04bf840d4f25bda6e5cf46dfe8177f33f8ea5ab5e90d17992272c6b3a931976f3a6328d513e943becbc4f9e46d89bce4f9c9654698252d7b09469015ea2c36862d
Private key: afcaf34d4647a3e50b39029fb34aa94b59ae75606f57d78e4bcb286948ed4816
```



<!-- TODO: add install doc and res folder -->

## cmd examples

### wrap token (ex: in bsc bnb -> wbnb, in eth eth -> weth, in polygon matic -> wmatic )

```bash
cargo run -- wrap --network bsc --wallet test-wallet --amount 0.005
```

---

### unwrap token (ex: in bsc wbnb -> bnb, in eth weth -> eth, in polygon wmatic -> matic )

```bash
cargo run -- unwrap --network bsc --wallet test-wallet --amount 0.005
```
**WARNING: this is the `v0.2-dev`, a branch with the in development progress of the mfm v0.2**; the [v0.1 was moved to `v0.1` branch](https://github.com/willyrgf/mfm/tree/v0.1).

---

### check allowance data for an asset

```bash
cargo run -- allowance -e pancake_swap_v2 -w test-wallet -a wbnb
```

---

### approve spender for an asset

```bash
cargo run -- approve -e pancake_swap_v2 -w test-wallet -a wbnb -v 10
```


#### To approve all assets
```bash
cargo run -- allowance --network polygon --wallet test-wallet |
grep ^\| |
grep -v Exchange |
awk -F '|' '{print $2 $3}' |
xargs -n 2 bash -c 'cargo run -- approve --exchange $0 -w test-wallet --asset $1 --amount 10000000'
```

---

### get a quote

```bash
cargo run -- quote --network bsc --exchange pancake_swap_v2 -i wbnb -o busd -a 1.0
```

---

### swap tokens for tokens supporting fees on transfer

```bash
cargo run -- swap -w test-wallet -n bsc -e pancake_swap_v2 -i wbnb -o busd -a 0.0006
```

---

### get balances of assets from wallet

```bash
cargo run -- balances -w test-wallet
```

---

### run rebalancer

```bash
cargo run -- rebalancer -n test-rebalancer
```

---

### run withdraw

```bash
cargo run -- withdraw --wallet test-wallet --network bsc --withdraw-wallet test-wallet2 -v 0.008 -a wbnb
```
31 changes: 0 additions & 31 deletions build.rs

This file was deleted.

26 changes: 0 additions & 26 deletions default.nix

This file was deleted.

Loading
Loading