From cf3323294710ec6da058912982b587768d66d8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Willy=20Rom=C3=A3o?= Date: Sun, 26 Nov 2023 14:34:18 +0000 Subject: [PATCH] cleanup old v0.1 and make it an workspace for all mfm crates --- Cargo.lock | 2971 ++--------------- Cargo.toml | 50 +- README.md | 145 +- build.rs | 31 - default.nix | 26 - example_config.yaml | 327 -- flake.lock | 130 - flake.nix | 26 - mfm_cli/Cargo.toml | 14 + {src => mfm_cli/src}/lib.rs | 18 - {src => mfm_cli/src}/main.rs | 19 +- {src => mfm_cli/src}/telemetry.rs | 0 mfm_machine/Cargo.toml | 14 +- mfm_machine/src/lib.rs | 2 +- mfm_machine/src/state/context.rs | 1 + mfm_machine/src/state/mod.rs | 35 +- mfm_machine/src/state_machine/mod.rs | 10 +- mfm_machine/src/state_machine/tracker.rs | 11 +- mfm_machine/tests/default_impls.rs | 5 +- mfm_machine_derive/Cargo.toml | 13 + .../mfm_machine_macros/Cargo.toml | 0 .../mfm_machine_macros/src/lib.rs | 0 mfm_machine_derive/src/lib.rs | 33 + res/assets/bsc/anonq/abi.json | 775 ----- res/assets/bsc/btcb/abi.json | 293 -- res/assets/bsc/busd/abi.json | 486 --- res/assets/bsc/cake/abi.json | 630 ---- res/assets/bsc/eth/abi.json | 293 -- res/assets/bsc/posi/abi.json | 906 ----- res/assets/bsc/safemoon/abi.json | 678 ---- res/assets/bsc/wbnb/abi.json | 293 -- res/assets/erc20_abi.json | 279 -- res/exchanges/pancake_swap_v2/abi.json | 397 --- .../pancake_swap_v2/factory_abi.json | 208 -- res/exchanges/uniswap_v2_factory_abi.json | 208 -- res/exchanges/uniswap_v2_pair_abi.json | 454 --- res/exchanges/uniswap_v2_router_abi.json | 397 --- src/allowance/cmd.rs | 13 - src/allowance/mod.rs | 37 - src/approve/cmd.rs | 23 - src/approve/mod.rs | 37 - src/approve_all/cmd.rs | 24 - src/approve_all/mod.rs | 45 - src/asset/config.rs | 89 - src/asset/mod.rs | 401 --- src/balances/cmd.rs | 18 - src/balances/mod.rs | 60 - src/cmd/enc.rs | 0 src/cmd/helpers.rs | 259 -- src/cmd/mod.rs | 101 - src/config/decrypt_wallet.rs | 25 - src/config/exchange.rs | 497 --- src/config/exchange/swap_eth_for_tokens.rs | 79 - src/config/exchange/swap_tokens_for_tokens.rs | 131 - src/config/mod.rs | 65 - src/config/network.rs | 153 - src/config/wallet.rs | 83 - src/config/withdraw_wallet.rs | 29 - src/encrypt/cmd.rs | 10 - src/encrypt/mod.rs | 24 - src/notification/config.rs | 28 - src/notification/debug.rs | 11 - src/notification/mod.rs | 20 - src/notification/telegram.rs | 34 - src/quote/cmd.rs | 26 - src/quote/mod.rs | 69 - src/rebalancer/cmd.rs | 398 --- src/rebalancer/config.rs | 254 -- src/rebalancer/mod.rs | 657 ---- src/swap/cmd.rs | 27 - src/swap/mod.rs | 86 - src/track/cmd.rs | 15 - src/track/mod.rs | 236 -- src/unwrap/cmd.rs | 18 - src/unwrap/mod.rs | 17 - src/utils/blockchain.rs | 149 - src/utils/hidden.rs | 95 - src/utils/math.rs | 116 - src/utils/mod.rs | 7 - src/utils/password.rs | 142 - src/utils/resources.rs | 25 - src/utils/scalar.rs | 577 ---- src/utils/signing.rs | 11 - src/watcher/cmd.rs | 15 - src/watcher/mod.rs | 72 - src/withdraw/cmd.rs | 29 - src/withdraw/mod.rs | 32 - src/wrap/cmd.rs | 24 - src/wrap/mod.rs | 17 - test_config.yaml | 321 -- tests/blockchains/gethnet/Dockerfile | 26 - ...--4e22e05c29a7165aeee0d813be03af17f129a2d1 | 1 - tests/blockchains/gethnet/genesis.json | 22 - tests/blockchains/gethnet/password.txt | 0 tests/common.rs | 57 - tests/network.rs | 66 - 96 files changed, 370 insertions(+), 15711 deletions(-) delete mode 100644 build.rs delete mode 100644 default.nix delete mode 100644 example_config.yaml delete mode 100644 flake.lock delete mode 100644 flake.nix create mode 100644 mfm_cli/Cargo.toml rename {src => mfm_cli/src}/lib.rs (84%) rename {src => mfm_cli/src}/main.rs (67%) rename {src => mfm_cli/src}/telemetry.rs (100%) create mode 100644 mfm_machine_derive/Cargo.toml rename {mfm_machine => mfm_machine_derive}/mfm_machine_macros/Cargo.toml (100%) rename {mfm_machine => mfm_machine_derive}/mfm_machine_macros/src/lib.rs (100%) create mode 100644 mfm_machine_derive/src/lib.rs delete mode 100644 res/assets/bsc/anonq/abi.json delete mode 100644 res/assets/bsc/btcb/abi.json delete mode 100644 res/assets/bsc/busd/abi.json delete mode 100644 res/assets/bsc/cake/abi.json delete mode 100644 res/assets/bsc/eth/abi.json delete mode 100644 res/assets/bsc/posi/abi.json delete mode 100644 res/assets/bsc/safemoon/abi.json delete mode 100644 res/assets/bsc/wbnb/abi.json delete mode 100644 res/assets/erc20_abi.json delete mode 100644 res/exchanges/pancake_swap_v2/abi.json delete mode 100644 res/exchanges/pancake_swap_v2/factory_abi.json delete mode 100644 res/exchanges/uniswap_v2_factory_abi.json delete mode 100644 res/exchanges/uniswap_v2_pair_abi.json delete mode 100644 res/exchanges/uniswap_v2_router_abi.json delete mode 100644 src/allowance/cmd.rs delete mode 100644 src/allowance/mod.rs delete mode 100644 src/approve/cmd.rs delete mode 100644 src/approve/mod.rs delete mode 100644 src/approve_all/cmd.rs delete mode 100644 src/approve_all/mod.rs delete mode 100644 src/asset/config.rs delete mode 100644 src/asset/mod.rs delete mode 100644 src/balances/cmd.rs delete mode 100644 src/balances/mod.rs delete mode 100644 src/cmd/enc.rs delete mode 100644 src/cmd/helpers.rs delete mode 100644 src/cmd/mod.rs delete mode 100644 src/config/decrypt_wallet.rs delete mode 100644 src/config/exchange.rs delete mode 100644 src/config/exchange/swap_eth_for_tokens.rs delete mode 100644 src/config/exchange/swap_tokens_for_tokens.rs delete mode 100644 src/config/mod.rs delete mode 100644 src/config/network.rs delete mode 100644 src/config/wallet.rs delete mode 100644 src/config/withdraw_wallet.rs delete mode 100644 src/encrypt/cmd.rs delete mode 100644 src/encrypt/mod.rs delete mode 100644 src/notification/config.rs delete mode 100644 src/notification/debug.rs delete mode 100644 src/notification/mod.rs delete mode 100644 src/notification/telegram.rs delete mode 100644 src/quote/cmd.rs delete mode 100644 src/quote/mod.rs delete mode 100644 src/rebalancer/cmd.rs delete mode 100644 src/rebalancer/config.rs delete mode 100644 src/rebalancer/mod.rs delete mode 100644 src/swap/cmd.rs delete mode 100644 src/swap/mod.rs delete mode 100644 src/track/cmd.rs delete mode 100644 src/track/mod.rs delete mode 100644 src/unwrap/cmd.rs delete mode 100644 src/unwrap/mod.rs delete mode 100644 src/utils/blockchain.rs delete mode 100644 src/utils/hidden.rs delete mode 100644 src/utils/math.rs delete mode 100644 src/utils/mod.rs delete mode 100644 src/utils/password.rs delete mode 100644 src/utils/resources.rs delete mode 100644 src/utils/scalar.rs delete mode 100644 src/utils/signing.rs delete mode 100644 src/watcher/cmd.rs delete mode 100644 src/watcher/mod.rs delete mode 100644 src/withdraw/cmd.rs delete mode 100644 src/withdraw/mod.rs delete mode 100644 src/wrap/cmd.rs delete mode 100644 src/wrap/mod.rs delete mode 100644 test_config.yaml delete mode 100644 tests/blockchains/gethnet/Dockerfile delete mode 100644 tests/blockchains/gethnet/data/keystore/UTC--2023-03-28T01-13-34.803419000Z--4e22e05c29a7165aeee0d813be03af17f129a2d1 delete mode 100644 tests/blockchains/gethnet/genesis.json delete mode 100644 tests/blockchains/gethnet/password.txt delete mode 100644 tests/common.rs delete mode 100644 tests/network.rs diff --git a/Cargo.lock b/Cargo.lock index b5806a5..cdeaa81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,2516 +2,500 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", - "opaque-debug", -] - [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] -name = "android-tzdata" -version = "0.1.1" +name = "aho-corasick" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] [[package]] -name = "android_system_properties" -version = "0.1.5" +name = "anyhow" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] -name = "anstream" -version = "0.3.2" +name = "autocfg" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is-terminal", - "utf8parse", -] +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "anstyle" +name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "anstyle-parse" -version = "0.2.0" +name = "deranged" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ - "utf8parse", + "powerfmt", ] [[package]] -name = "anstyle-query" -version = "1.0.0" +name = "gethostname" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" dependencies = [ - "windows-sys 0.48.0", + "libc", + "winapi", ] [[package]] -name = "anstyle-wincon" -version = "1.0.1" +name = "getrandom" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ - "anstyle", - "windows-sys 0.48.0", + "cfg-if", + "libc", + "wasi", ] [[package]] -name = "anyhow" -version = "1.0.75" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] -name = "aquamarine" -version = "0.1.12" +name = "indexmap" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941c39708478e8eea39243b5983f1c42d2717b3620ee91f4a52115fd02ac43f" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "itertools", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", + "autocfg", + "hashbrown", ] [[package]] -name = "arrayvec" -version = "0.7.2" +name = "itoa" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] -name = "autocfg" -version = "1.1.0" +name = "lazy_static" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "base64" -version = "0.13.1" +name = "libc" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] -name = "base64" -version = "0.21.2" +name = "log" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] -name = "bigdecimal" -version = "0.3.1" +name = "matchers" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "serde", + "regex-automata 0.1.10", ] [[package]] -name = "bitflags" -version = "1.3.2" +name = "memchr" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] -name = "bitvec" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +name = "mfm" +version = "0.1.29" dependencies = [ - "funty", - "radium", - "tap", - "wyz", + "serde", + "serde_json", + "serde_yaml", + "tracing", + "tracing-bunyan-formatter", + "tracing-log 0.1.4", + "tracing-subscriber", ] [[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +name = "mfm_machine" +version = "0.1.0" dependencies = [ - "block-padding", - "generic-array", + "anyhow", + "mfm_machine_derive", + "rand", + "serde", + "serde_derive", + "serde_json", ] [[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +name = "mfm_machine_derive" +version = "0.1.0" dependencies = [ - "generic-array", + "quote", + "syn 1.0.109", ] [[package]] -name = "block-modes" -version = "0.8.1" +name = "nu-ansi-term" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ - "block-padding", - "cipher", + "overload", + "winapi", ] [[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - -[[package]] -name = "bumpalo" -version = "3.13.0" +name = "once_cell" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] -name = "byte-slice-cast" -version = "1.2.2" +name = "overload" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] -name = "byteorder" -version = "1.4.3" +name = "pin-project-lite" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] -name = "bytes" -version = "1.4.0" +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] -name = "cc" -version = "1.0.79" +name = "ppv-lite86" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] -name = "cfg-if" -version = "1.0.0" +name = "proc-macro2" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] [[package]] -name = "chrono" -version = "0.4.25" +name = "quote" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbc37d37da9e5bce8173f3a41b71d9bf3c674deebbaceacd0ebdabde76efb03" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "time 0.1.45", - "wasm-bindgen", - "winapi", + "proc-macro2", ] [[package]] -name = "cipher" -version = "0.3.0" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "generic-array", + "libc", + "rand_chacha", + "rand_core", ] [[package]] -name = "clap" -version = "4.3.0" +name = "rand_chacha" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ - "clap_builder", - "clap_derive", - "once_cell", + "ppv-lite86", + "rand_core", ] [[package]] -name = "clap_builder" -version = "4.3.0" +name = "rand_core" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "anstream", - "anstyle", - "bitflags", - "clap_lex", - "once_cell", - "strsim", + "getrandom", ] [[package]] -name = "clap_derive" -version = "4.3.0" +name = "regex" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.39", + "aho-corasick", + "memchr", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] -name = "clap_lex" -version = "0.5.0" +name = "regex-automata" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] [[package]] -name = "colorchoice" -version = "1.0.0" +name = "regex-automata" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", +] [[package]] -name = "convert_case" -version = "0.4.0" +name = "regex-syntax" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "core-foundation" -version = "0.9.3" +name = "regex-syntax" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] -name = "core-foundation-sys" -version = "0.8.4" +name = "ryu" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] -name = "cpufeatures" -version = "0.2.7" +name = "serde" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ - "libc", + "serde_derive", ] [[package]] -name = "crc-any" -version = "2.4.3" +name = "serde_derive" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774646b687f63643eb0f4bf13dc263cb581c8c9e57973b6ddf78bda3994d88df" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ - "debug-helper", + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-common" -version = "0.1.6" +name = "serde_json" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ - "generic-array", - "typenum", + "itoa", + "ryu", + "serde", ] [[package]] -name = "csv" -version = "1.2.1" +name = "serde_yaml" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" +checksum = "d9d684e3ec7de3bf5466b32bd75303ac16f0736426e5a4e0d6e489559ce1249c" dependencies = [ - "csv-core", + "indexmap", "itoa", "ryu", "serde", + "unsafe-libyaml", ] [[package]] -name = "csv-core" -version = "0.1.10" +name = "sharded-slab" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ - "memchr", + "lazy_static", ] [[package]] -name = "ct-codecs" -version = "1.1.1" +name = "smallvec" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] -name = "darling" -version = "0.13.4" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "darling_core", - "darling_macro", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "darling_core" -version = "0.13.4" +name = "syn" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ - "fnv", - "ident_case", "proc-macro2", "quote", - "strsim", - "syn 1.0.109", + "unicode-ident", ] [[package]] -name = "darling_macro" -version = "0.13.4" +name = "thread_local" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", + "cfg-if", + "once_cell", ] [[package]] -name = "debug-helper" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e" - -[[package]] -name = "derive_more" -version = "0.99.17" +name = "time" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", ] [[package]] -name = "des" -version = "0.7.0" +name = "time-core" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac41dd49fb554432020d52c875fc290e110113f864c6b1b525cd62c7e7747a5d" -dependencies = [ - "byteorder", - "cipher", - "opaque-debug", -] +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] -name = "digest" -version = "0.9.0" +name = "time-macros" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ - "generic-array", + "time-core", ] [[package]] -name = "digest" -version = "0.10.7" +name = "tracing" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "block-buffer 0.10.4", - "crypto-common", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", ] [[package]] -name = "dirs-next" -version = "2.0.0" +name = "tracing-attributes" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "cfg-if", - "dirs-sys-next", + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] -name = "dirs-sys-next" -version = "0.1.2" +name = "tracing-bunyan-formatter" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +checksum = "b5c266b9ac83dedf0e0385ad78514949e6d89491269e7065bee51d2bb8ec7373" dependencies = [ - "libc", - "redox_users", - "winapi", + "ahash", + "gethostname", + "log", + "serde", + "serde_json", + "time", + "tracing", + "tracing-core", + "tracing-log 0.1.4", + "tracing-subscriber", ] [[package]] -name = "dptree" -version = "0.3.0" +name = "tracing-core" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81175dab5ec79c30e0576df2ed2c244e1721720c302000bb321b107e82e265c" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ - "futures", + "once_cell", + "valuable", ] [[package]] -name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "encode_unicode" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" - -[[package]] -name = "encoding_rs" -version = "0.8.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "erasable" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f11890ce181d47a64e5d1eb4b6caba0e7bae911a356723740d058a5d0340b7d" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "ethabi" -version = "16.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c98847055d934070b90e806e12d3936b787d0a115068981c1d8dfd5dfef5a5" -dependencies = [ - "ethereum-types", - "hex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-rlp", - "impl-serde", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-rlp", - "impl-serde", - "primitive-types", - "uint", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fiat-crypto" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" - -[[package]] -name = "fixed-hash" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "funty" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" - -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-executor" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "gethostname" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "getrandom" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "h2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util 0.7.8", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "headers" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" -dependencies = [ - "base64 0.13.1", - "bitflags", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "hyper" -version = "0.14.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "impl-codec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "ipnet" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" - -[[package]] -name = "is-terminal" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" -dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", -] - -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" - -[[package]] -name = "js-sys" -version = "0.3.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" -dependencies = [ - "futures", - "futures-executor", - "futures-util", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.144" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" - -[[package]] -name = "magic-crypt" -version = "3.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0196bd5c76f5f51d7d6563545f86262fef4c82d75466ba6f6d359c40a523318d" -dependencies = [ - "aes", - "base64 0.13.1", - "block-modes", - "crc-any", - "des", - "digest 0.9.0", - "md-5", - "sha2", - "tiger", -] - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata", -] - -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - -[[package]] -name = "md-5" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "mfm" -version = "0.1.29" -dependencies = [ - "anyhow", - "bigdecimal", - "chrono", - "clap", - "futures", - "hex", - "magic-crypt", - "num-bigint", - "num-traits", - "once_cell", - "orion", - "phf", - "phf_codegen", - "prettytable-rs", - "reqwest", - "rpassword", - "rustc-hex", - "secp256k1", - "serde", - "serde_json", - "serde_yaml", - "teloxide", - "thiserror", - "tokio", - "tracing", - "tracing-bunyan-formatter", - "tracing-log", - "tracing-subscriber", - "walkdir", - "web3", - "zeroize", -] - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - -[[package]] -name = "mio" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebffdb73fe72e917997fad08bdbf31ac50b0fa91cec93e69a0662e4264d454c" -dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "never" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96aba5aa877601bb3f6dd6a63a969e1f82e60646e81e71b14496995e9853c91" - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", - "serde", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "orion" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbe74a766292f94f7e69db5a7bf010eadd944f24186c463fe578a7e637582066" -dependencies = [ - "ct-codecs", - "fiat-crypto", - "getrandom", - "subtle", - "zeroize", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "parity-scale-codec" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "windows-sys 0.45.0", -] - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "phf" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" -dependencies = [ - "phf_shared", - "rand", -] - -[[package]] -name = "phf_shared" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "prettytable-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea25e07510aa6ab6547308ebe3c036016d162b8da920dbb079e3ba8acf3d95a" -dependencies = [ - "csv", - "encode_unicode", - "is-terminal", - "lazy_static", - "term", - "unicode-width", -] - -[[package]] -name = "primitive-types" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rc-box" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0690759eabf094030c2cdabc25ade1395bac02210d920d655053c1d49583fd8" -dependencies = [ - "erasable", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall 0.2.16", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" -dependencies = [ - "regex-syntax 0.7.2", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" - -[[package]] -name = "reqwest" -version = "0.11.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" -dependencies = [ - "base64 0.21.2", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "mime_guess", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "tokio-util 0.7.8", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", - "winreg", -] - -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rustc-hex", -] - -[[package]] -name = "rpassword" -version = "7.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" -dependencies = [ - "libc", - "rtoolbox", - "winapi", -] - -[[package]] -name = "rtoolbox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.37.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustversion" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" - -[[package]] -name = "ryu" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys 0.42.0", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "secp256k1" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" -dependencies = [ - "cc", -] - -[[package]] -name = "security-framework" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" - -[[package]] -name = "serde" -version = "1.0.192" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.192" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "serde_json" -version = "1.0.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_with_macros" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "serde_yaml" -version = "0.9.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d684e3ec7de3bf5466b32bd75303ac16f0736426e5a4e0d6e489559ce1249c" -dependencies = [ - "indexmap", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "keccak", - "opaque-debug", -] - -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "siphasher" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" - -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "soketto" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" -dependencies = [ - "base64 0.13.1", - "bytes", - "futures", - "httparse", - "log", - "rand", - "sha-1", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" - -[[package]] -name = "takecell" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20f34339676cdcab560c9a82300c4c2581f68b9369aedf0fae86f2ff9565ff3e" - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "teloxide" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c63345cf32a8850ebddcdd769dc2d5193d5e231262d5dada264b79da01a664da" -dependencies = [ - "aquamarine", - "bytes", - "derive_more", - "dptree", - "futures", - "log", - "mime", - "pin-project", - "serde", - "serde_json", - "serde_with_macros", - "teloxide-core", - "thiserror", - "tokio", - "tokio-stream", - "tokio-util 0.7.8", - "url", -] - -[[package]] -name = "teloxide-core" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "303db260110c238e3af77bb9dff18bf7a5b5196f783059b0852aab75f91d5a16" -dependencies = [ - "bitflags", - "bytes", - "chrono", - "derive_more", - "either", - "futures", - "log", - "mime", - "never", - "once_cell", - "pin-project", - "rc-box", - "reqwest", - "serde", - "serde_json", - "serde_with_macros", - "take_mut", - "takecell", - "thiserror", - "tokio", - "tokio-util 0.7.8", - "url", - "uuid", -] - -[[package]] -name = "tempfile" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall 0.3.5", - "rustix", - "windows-sys 0.45.0", -] - -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "tiger" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443e531cbcf9de83258cfef70bcd56c91188de5819ebd4b19c85f589e0617005" -dependencies = [ - "block-buffer 0.9.0", - "byteorder", - "digest 0.9.0", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "time" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" -dependencies = [ - "itoa", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" -dependencies = [ - "time-core", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.28.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" -dependencies = [ - "autocfg", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes", - "futures-core", - "futures-io", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml_datetime" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" - -[[package]] -name = "toml_edit" -version = "0.19.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "tracing-bunyan-formatter" -version = "0.3.7" +name = "tracing-log" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a348912d4e90923cb93343691d3be97e3409607363706c400fc935bb032fb0" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "ahash", - "gethostname", "log", - "serde", - "serde_json", - "time 0.3.21", - "tracing", - "tracing-core", - "tracing-log", - "tracing-subscriber", -] - -[[package]] -name = "tracing-core" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" -dependencies = [ "once_cell", - "valuable", + "tracing-core", ] [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -2522,289 +506,39 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", + "tracing-log 0.2.0", ] -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - [[package]] name = "unicode-ident" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unsafe-libyaml" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1865806a559042e51ab5414598446a5871b561d21b6764f2eabb0dd481d880a6" -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna 0.3.0", - "percent-encoding", - "serde", -] - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "uuid" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" -dependencies = [ - "getrandom", -] - [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "walkdir" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.39", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" - -[[package]] -name = "wasm-streams" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "web-sys" -version = "0.3.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web3" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f258e254752d210b84fe117b31f1e3cc9cbf04c0d747eb7f8cf7cf5e370f6d" -dependencies = [ - "arrayvec", - "base64 0.13.1", - "bytes", - "derive_more", - "ethabi", - "ethereum-types", - "futures", - "futures-timer", - "headers", - "hex", - "idna 0.2.3", - "jsonrpc-core", - "log", - "once_cell", - "parking_lot", - "pin-project", - "reqwest", - "rlp", - "secp256k1", - "serde", - "serde_json", - "soketto", - "tiny-keccak", - "tokio", - "tokio-stream", - "tokio-util 0.6.10", - "url", - "web3-async-native-tls", -] - -[[package]] -name = "web3-async-native-tls" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6d8d1636b2627fe63518d5a9b38a569405d9c9bc665c43c9c341de57227ebb" -dependencies = [ - "native-tls", - "thiserror", - "tokio", - "url", -] - [[package]] name = "winapi" version = "0.3.9" @@ -2821,15 +555,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2837,187 +562,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" -dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" +name = "zerocopy" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "zerocopy-derive", ] [[package]] -name = "windows-targets" -version = "0.48.0" +name = "zerocopy-derive" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "winnow" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", + "proc-macro2", + "quote", + "syn 2.0.39", ] - -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - -[[package]] -name = "zeroize" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/Cargo.toml b/Cargo.toml index 785fd44..5da1285 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", +] diff --git a/README.md b/README.md index dae0ec5..cca9f97 100644 --- a/README.md +++ b/README.md @@ -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 -``` - - - - - -## 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 -``` diff --git a/build.rs b/build.rs deleted file mode 100644 index dd26c73..0000000 --- a/build.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::env; -use std::fs::File; -use std::io::{BufWriter, Write}; -use std::path::Path; -use walkdir::WalkDir; - -fn main() { - let path = Path::new(&env::var("OUT_DIR").unwrap()).join("res.rs"); - let mut file_dest = BufWriter::new(File::create(&path).unwrap()); - let mut map = phf_codegen::Map::new(); - - for dir_entry in WalkDir::new("res").into_iter().filter_map(|dir| match dir { - Ok(d) if d.file_type().is_file() => Some(d), - Ok(_) => None, - Err(_) => None, - }) { - let path = dir_entry.path().to_str().unwrap().to_owned(); - let file = std::fs::read_to_string(path.clone()).unwrap(); - map.entry( - path.to_owned(), - &format!("\"{}\"", file.as_str().escape_default()), - ); - } - - writeln!( - &mut file_dest, - "static RES: phf::Map<&'static str, &'static str> = \n{};", - map.build() - ) - .unwrap(); -} diff --git a/default.nix b/default.nix deleted file mode 100644 index 5d530f6..0000000 --- a/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ pkgs }: -let - common = { - version = "0.1.29"; - src = ./.; - - cargoLock = { - lockFile = ./Cargo.lock; - }; - - buildInputs = with pkgs;[ - darwin.apple_sdk.frameworks.Security - pkg-config - openssl - ]; - }; -in { - mfm = pkgs.rustPlatform.buildRustPackage (common // { - pname = "mfm"; - meta = { - description = "An Nix module for MFM CLI"; - license = pkgs.lib.licenses.mit; - homepage = "https://github.com/willyrgf/mfm"; - }; - }); -} diff --git a/example_config.yaml b/example_config.yaml deleted file mode 100644 index d19b848..0000000 --- a/example_config.yaml +++ /dev/null @@ -1,327 +0,0 @@ -server: - api_url: http://127.0.0.1:8000 - api_token: 04e802e3-4a66-4ad6-acb9-ae184673ad55 - -wallets: - test-wallet: - private_key: YOUR_PRIVATE_KEY - farm-wallet: - private_key: - YOUR_PRIVATE_KEY - # encrypted: true - # env_password: MFM_TEST_WALLET_PASSWORD # default is MFM_WALLET_PASSWORD if `encrypted`` is true - geth-wallet: - private_key: afcaf34d4647a3e50b39029fb34aa94b59ae75606f57d78e4bcb286948ed4816 - -withdraw_wallets: - test-wallet2: - address: YOUR_PUBLIC_ADDRESS - -networks: - bsc: - name: bsc - symbol: bnb - chain_id: 56 - rpc_url: https://bsc-dataseed.binance.org - blockexplorer_url: https://bscscan.com - min_balance_coin: 0.1 - wrapped_asset: wbnb - decimals: 18 - polygon: - name: polygon - symbol: matic - chain_id: 137 - rpc_url: https://polygon-rpc.com/ - node_url_http: https://polygon.llamarpc.com # optional, will be used to filter logs if exists - blockexplorer_url: https://polygonscan.com/ - min_balance_coin: 1 - wrapped_asset: wmatic - decimals: 18 - geth: - name: geth - symbol: eth - chain_id: 1337 - rpc_url: http://127.0.0.1:8545 - node_url_http: http://127.0.0.1:8545 - min_balance_coin: 1 - decimals: 18 - -exchanges: - pancake_swap_v2: - name: pancake_swap_v2 - router_address: 0x10ED43C718714eb63d5aA57B78B54704E256024E - factory_address: 0xca143ce32fe78f1f7019d7d551a6402fc5350c73 - network_id: bsc - quickswap_v2: - name: quickswap_v2 - router_address: 0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff - factory_address: 0x5757371414417b8c6caad45baef941abc7d3ab32 - network_id: polygon - sushi_swap_polygon: - name: susih_swap_polygon - router_address: 0x1b02da8cb0d097eb8d57a175b88c7d8b47997506 - factory_address: 0xc35dadb65012ec5796536bd9864ed8773abc74c4 - network_id: polygon - biswap: - name: biswap - router_address: 0x3a6d8ca21d1cf76f653a67577fa0d27453350dd8 - factory_address: 0x858e3312ed3a876947ea49d572a7c42de08af7ee - network_id: bsc - -# machines: -# farm-all-to-busd-vault: -# name: farm-all-to-busd-vault -# operations: -# collect_farms_and_swap: -# swap_to_asset_id: busd -# yield-farms: -# auto-cake: -# yield_farm_id: auto-cake -# posi-farm-bnb-posi: -# yield_farm_id: posi-farm-bnb-posi -# posi-farm-busd-posi: -# yield_farm_id: posi-farm-busd-posi -# withdraw: -# wallet_id: farm-wallet -# withdraw_wallet_id: busd-vault - -assets: - qidao: - kind: token - networks: - polygon: - name: qidao - network_id: polygon - address: 0x580a84c73811e1839f75d86d75d88cca0c241ff4 - slippage: 2 - path_asset: weth - dquick: - kind: token - networks: - polygon: - name: dquick - network_id: polygon - address: 0xf28164a485b0b2c90639e47b0f377b4a438a16b1 - slippage: 2 - path_asset: weth - xrp: - kind: token - networks: - bsc: - name: xrp - network_id: bsc - address: 0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE - slippage: 2 - path_asset: wbnb - link: - kind: token - networks: - bsc: - name: link - network_id: bsc - address: 0xF8A0BF9cF54Bb92F17374d9e9A321E6a111a51bD - slippage: 2 - path_asset: wbnb - gala: - kind: token - networks: - bsc: - name: gala - network_id: bsc - address: 0x7dDEE176F665cD201F93eEDE625770E2fD911990 - slippage: 2 - path_asset: wbnb - near: - kind: token - networks: - bsc: - name: near - network_id: bsc - address: 0x1Fa4a73a3F0133f0025378af00236f3aBDEE5D63 - slippage: 2 - path_asset: wbnb - luna: - kind: token - networks: - bsc: - name: luna - network_id: bsc - address: 0x156ab3346823B651294766e23e6Cf87254d68962 - slippage: 2 - path_asset: wbnb - wmatic: - kind: token - networks: - bsc: - name: wmatic - network_id: bsc - address: 0xcc42724c6683b7e57334c4e856f4c9965ed682bd - slippage: 2 - path_asset: wbnb - polygon: - name: wmatic - network_id: polygon - address: 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270 - slippage: 2 - path_asset: weth - anonq: - kind: token - networks: - bsc: - name: anonq - network_id: bsc - address: 0xf393138616cd6DD367171eaA59c2eaEE420a32b9 - slippage: 2 - path_asset: wbnb - busd: - kind: token - networks: - bsc: - name: busd - network_id: bsc - address: 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56 - slippage: 2 - path_asset: wbnb - wbnb: - kind: token - networks: - bsc: - name: wbnb - network_id: bsc - address: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c - slippage: 2 - path_asset: wbnb - weth: - kind: token - networks: - bsc: - name: weth - network_id: bsc - address: 0x2170ed0880ac9a755fd29b2688956bd959f933f8 - slippage: 2 - path_asset: wbnb - polygon: - name: weth - network_id: polygon - address: 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619 - slippage: 2 - path_asset: weth - btc: - kind: token - networks: - bsc: - name: btc - network_id: bsc - address: 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c - slippage: 2 - path_asset: wbnb - sol: - kind: token - networks: - bsc: - name: sol - network_id: bsc - address: 0x570A5D26f7765Ecb712C0924E4De545B89fD43dF - slippage: 2 - path_asset: wbnb - posi: - kind: token - networks: - bsc: - name: posi - network_id: bsc - address: 0x5ca42204cdaa70d5c773946e69de942b85ca6706 - slippage: 2 - path_asset: wbnb - cake: - kind: token - networks: - bsc: - name: cake - network_id: bsc - address: 0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82 - slippage: 2 - path_asset: wbnb - pacoca: - kind: token - networks: - bsc: - name: pacoca - network_id: bsc - address: 0x55671114d774ee99d653d6c12460c780a67f1d18 - slippage: 1 - path_asset: wbnb - safemoon: - kind: token - networks: - bsc: - name: safemoon - network_id: bsc - address: 0x42981d0bfbAf196529376EE702F2a9Eb9092fcB5 - slippage: 1 - path_asset: wbnb - grt: - kind: token - networks: - polygon: - name: grt - network_id: polygon - address: 0x5fe2b58c013d7601147dcdd68c143a77499f5531 - slippage: 1 - path_asset: weth - usdc: - kind: token - networks: - polygon: - name: usdc - network_id: polygon - address: 0x2791bca1f2de4661ed88a30c99a7a9449aa84174 - slippage: 1 - path_asset: wmatic - bsc: - name: usdc - network_id: bsc - address: 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d - slippage: 1 - path_asset: wbnb - usdt: - kind: token - networks: - bsc: - name: usdt - network_id: bsc - address: 0x55d398326f99059ff775485246999027b3197955 - slippage: 1 - path_asset: wbnb - baby: - kind: token - networks: - bsc: - name: baby - network_id: bsc - address: 0x53e562b9b7e5e94b81f10e96ee70ad06df3d2657 - slippage: 1 - path_asset: usdt - -rebalancers: - test-rebalancer: - name: test-anonq-busd - network_id: bsc - wallet_id: test-wallet - portfolio: - anonq: - percent: 40 - busd: - percent: 25 - wbnb: - percent: 25 - eth: - percent: 5 - btc: - percent: 5 - strategy: full_parking #diff_parking - # if zero, always run - threshold_percent: 2 - quoted_in: busd - parking_asset_id: busd - parking_asset_min_move: 0.01 diff --git a/flake.lock b/flake.lock deleted file mode 100644 index d10f47b..0000000 --- a/flake.lock +++ /dev/null @@ -1,130 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1696019113, - "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1681358109, - "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1696126582, - "narHash": "sha256-uo4cn/d2rHPy/fpKZKFBOaVO531zs/Doxz43imrpqZM=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "fc6fe50d9a4540a1111731baaa00f207301fdeb7", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index fbeefc3..0000000 --- a/flake.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ - description = "A flake for the MFM CLI"; - - inputs = { - rust-overlay.url = "github:oxalica/rust-overlay"; - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { nixpkgs, rust-overlay, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { - inherit system overlays; - }; - - packages = pkgs.callPackage ./. {}; - in - { - packages = { - default = packages.mfm; - }; - } - ); -} diff --git a/mfm_cli/Cargo.toml b/mfm_cli/Cargo.toml new file mode 100644 index 0000000..086ba5a --- /dev/null +++ b/mfm_cli/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "mfm" +version = "0.1.29" +edition = "2021" + +[dependencies] +serde_yaml = "0.9" +serde_json = "1.0" +serde = { version = "1.0", features = ["derive"] } +tracing = { version = "0.1", features = [ "log" ] } +tracing-subscriber = { version = "0.3", features = [ "registry", "env-filter" ] } +tracing-bunyan-formatter = "0.3" +tracing-log = "0.1" + diff --git a/src/lib.rs b/mfm_cli/src/lib.rs similarity index 84% rename from src/lib.rs rename to mfm_cli/src/lib.rs index c1c77a7..7c9267c 100644 --- a/src/lib.rs +++ b/mfm_cli/src/lib.rs @@ -1,22 +1,4 @@ -pub mod allowance; -pub mod approve; -pub mod asset; -pub mod balances; -pub mod cmd; -pub mod config; -pub mod encrypt; -pub mod notification; -pub mod quote; -pub mod rebalancer; -pub mod swap; pub mod telemetry; -pub mod track; -pub mod unwrap; -pub mod utils; -pub mod watcher; -pub mod withdraw; -pub mod wrap; -pub mod approve_all; pub const APP_NAME: &str = "mfm"; pub const DEFAULT_LOG_LEVEL: &str = "info"; diff --git a/src/main.rs b/mfm_cli/src/main.rs similarity index 67% rename from src/main.rs rename to mfm_cli/src/main.rs index 43f7b2b..87985a8 100644 --- a/src/main.rs +++ b/mfm_cli/src/main.rs @@ -1,12 +1,9 @@ -extern crate prettytable; use mfm::{ - cmd, telemetry::{get_subscriber, init_subscriber}, ExitCode, APP_NAME, DEFAULT_LOG_LEVEL, }; -#[tokio::main] -async fn main() { +fn main() { // This idiom is the prescribed way to get a clean shutdown of Rust (that will report // no leaks in Valgrind or sanitizers). Calling `unsafe { libc::exit() }` does no // cleanup, and std::process::exit() does more--but does not run destructors. So the @@ -14,23 +11,15 @@ async fn main() { // only exit when everything potentially destructible has cleaned itself up. // // https://doc.rust-lang.org/std/process/fn.exit.html - // - let exit_code = main_exitable().await; + let exit_code = main_exitable(); std::process::exit(exit_code as i32); } #[tracing::instrument(name = "main exitable")] -async fn main_exitable() -> ExitCode { +fn main_exitable() -> ExitCode { let subscriber = get_subscriber(APP_NAME.into(), DEFAULT_LOG_LEVEL.into(), std::io::stdout); init_subscriber(subscriber); - let command = cmd::new(); - match cmd::run(command).await { - Ok(_) => ExitCode::Ok, - Err(e) => { - tracing::error!("failed to execute cmd::run(), error: {}", e); - ExitCode::GenericError - } - } + unimplemented!() } diff --git a/src/telemetry.rs b/mfm_cli/src/telemetry.rs similarity index 100% rename from src/telemetry.rs rename to mfm_cli/src/telemetry.rs diff --git a/mfm_machine/Cargo.toml b/mfm_machine/Cargo.toml index cf90498..2b74cfd 100644 --- a/mfm_machine/Cargo.toml +++ b/mfm_machine/Cargo.toml @@ -3,19 +3,11 @@ name = "mfm_machine" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[workspace] -members = [ - ".", - "mfm_machine_macros", -] - - [dependencies] anyhow = "1.0.75" serde = "1.0.188" serde_derive = "1.0.189" serde_json = "1.0.107" -mfm_machine_macros = { path = "./mfm_machine_macros" } -rand = "0.8.5" +mfm_machine_derive = { path = "../mfm_machine_derive" } +rand = "0.8.5" + diff --git a/mfm_machine/src/lib.rs b/mfm_machine/src/lib.rs index 1a79ff3..f69cc83 100644 --- a/mfm_machine/src/lib.rs +++ b/mfm_machine/src/lib.rs @@ -1,6 +1,6 @@ pub mod state; pub mod state_machine; -pub use mfm_machine_macros::StateMetadataReqs; +extern crate mfm_machine_derive; //FIXME: reorganize library to be more ergonomic to use // see example in tests/public_api_test.rs how bad its. diff --git a/mfm_machine/src/state/context.rs b/mfm_machine/src/state/context.rs index b7da8db..27a7414 100644 --- a/mfm_machine/src/state/context.rs +++ b/mfm_machine/src/state/context.rs @@ -11,6 +11,7 @@ pub trait Context { } pub fn wrap_context(context: C) -> ContextWrapper { + #[allow(clippy::arc_with_non_send_sync)] Arc::new(Mutex::new(Box::new(context))) } diff --git a/mfm_machine/src/state/mod.rs b/mfm_machine/src/state/mod.rs index 426ee98..e491fba 100644 --- a/mfm_machine/src/state/mod.rs +++ b/mfm_machine/src/state/mod.rs @@ -1,13 +1,8 @@ use anyhow::{anyhow, Error, Result}; -use std::{ - fmt, - sync::{Arc, Mutex}, -}; +use std::{fmt, sync::Arc}; pub mod context; -use context::Context; - use self::context::ContextWrapper; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] @@ -30,8 +25,7 @@ fn ensure_nonempty_ascii_lowercase_underscore(input: &'static str) -> Result<&'s impl Tag { pub fn new(s: &'static str) -> Result { - let input = s.as_ref(); - match ensure_nonempty_ascii_lowercase_underscore(input) { + match ensure_nonempty_ascii_lowercase_underscore(s) { Ok(validated_input) => Ok(Self(validated_input)), Err(e) => Err(e), } @@ -40,9 +34,8 @@ impl Tag { impl Label { pub fn new(s: &'static str) -> Result { - let input = s.as_ref(); - match ensure_nonempty_ascii_lowercase_underscore(input) { - Ok(validated_input) => Ok(Self(validated_input.into())), + match ensure_nonempty_ascii_lowercase_underscore(s) { + Ok(validated_input) => Ok(Self(validated_input)), Err(e) => Err(e), } } @@ -151,33 +144,33 @@ mod test { #[test] fn test_valid_input_ensure_nonempty_ascii_lowercase_underscore() { - let inputs = vec!["this_should_work", "this_should_work_also", "thisalso"]; - - inputs.iter().for_each(|input| { - let result = ensure_nonempty_ascii_lowercase_underscore(input); - assert!(result.is_ok()); - assert_eq!(&result.unwrap(), input); - }) + ["this_should_work", "this_should_work_also", "thisalso"] + .iter() + .for_each(|input| { + let result = ensure_nonempty_ascii_lowercase_underscore(input); + assert!(result.is_ok()); + assert_eq!(&result.unwrap(), input); + }) } #[test] fn test_invalid_spaces_input_ensure_nonempty_ascii_lowercase_underscore() { let s = "this shouldnt work"; - let result = ensure_nonempty_ascii_lowercase_underscore(&s); + let result = ensure_nonempty_ascii_lowercase_underscore(s); assert!(result.is_err()); } #[test] fn test_empty_input_ensure_nonempty_ascii_lowercase_underscore() { let s = ""; - let result = ensure_nonempty_ascii_lowercase_underscore(&s); + let result = ensure_nonempty_ascii_lowercase_underscore(s); assert!(result.is_err()); } #[test] fn test_invalid_special_char_input_ensure_nonempty_ascii_lowercase_underscore() { let s = "this_should_not_work_@"; - let result = ensure_nonempty_ascii_lowercase_underscore(&s); + let result = ensure_nonempty_ascii_lowercase_underscore(s); assert!(result.is_err()); } } diff --git a/mfm_machine/src/state_machine/mod.rs b/mfm_machine/src/state_machine/mod.rs index 60b2504..75030e9 100644 --- a/mfm_machine/src/state_machine/mod.rs +++ b/mfm_machine/src/state_machine/mod.rs @@ -1,8 +1,8 @@ -use std::{sync::Arc, usize}; +use std::usize; use anyhow::anyhow; -use crate::state::{context::ContextWrapper, StateHandler, StateResult, States}; +use crate::state::{context::ContextWrapper, StateResult, States}; use self::tracker::{HashMapTracker, Index, Tracker}; @@ -148,6 +148,8 @@ impl StateMachine { #[cfg(test)] mod test { + use std::sync::Arc; + use crate::state::context::{wrap_context, ContextWrapper}; use crate::state::{ context::Context, DependencyStrategy, Label, StateHandler, StateMetadata, Tag, @@ -155,7 +157,7 @@ mod test { use crate::state::{StateError, StateErrorRecoverability}; use anyhow::anyhow; use anyhow::Error; - use mfm_machine_macros::StateMetadataReqs; + use mfm_machine_derive::StateMetadataReqs; use serde_derive::{Deserialize, Serialize}; use serde_json::{json, Value}; @@ -257,8 +259,6 @@ mod test { #[test] fn test_setup_state_initialization() { - use super::*; - let label = Label::new("setup_state").unwrap(); let tags = vec![Tag::new("setup").unwrap()]; let state = Setup::new(); diff --git a/mfm_machine/src/state_machine/tracker.rs b/mfm_machine/src/state_machine/tracker.rs index 4c2cdf4..d368d08 100644 --- a/mfm_machine/src/state_machine/tracker.rs +++ b/mfm_machine/src/state_machine/tracker.rs @@ -42,18 +42,23 @@ impl HashMapTracker { } } +impl Default for HashMapTracker { + fn default() -> Self { + Self::new() + } +} + impl Tracker for HashMapTracker { fn track(&mut self, index: Index, context: ContextWrapper) -> Result { Ok(self.0.insert(index, context).is_none()) } fn recover(&self, index: Index) -> Result { - Ok(self - .0 + self.0 .get(&index) .cloned() .clone() - .ok_or(anyhow!("index not found"))?) + .ok_or(anyhow!("index not found")) } fn search_by_tag(&self, tag: &Tag) -> Vec { diff --git a/mfm_machine/tests/default_impls.rs b/mfm_machine/tests/default_impls.rs index a987ef9..3cad381 100644 --- a/mfm_machine/tests/default_impls.rs +++ b/mfm_machine/tests/default_impls.rs @@ -1,6 +1,3 @@ -use std::sync::Arc; -use std::sync::Mutex; - use anyhow::anyhow; use anyhow::Error; use mfm_machine::state::context::Context; @@ -13,7 +10,7 @@ use mfm_machine::state::StateHandler; use mfm_machine::state::StateMetadata; use mfm_machine::state::StateResult; use mfm_machine::state::Tag; -use mfm_machine_macros::StateMetadataReqs; +use mfm_machine_derive::StateMetadataReqs; use rand::Rng; use serde_derive::{Deserialize, Serialize}; use serde_json::{json, Value}; diff --git a/mfm_machine_derive/Cargo.toml b/mfm_machine_derive/Cargo.toml new file mode 100644 index 0000000..2222bee --- /dev/null +++ b/mfm_machine_derive/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "mfm_machine_derive" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +proc-macro = true + +[dependencies] +syn = "1.0" +quote = "1.0" diff --git a/mfm_machine/mfm_machine_macros/Cargo.toml b/mfm_machine_derive/mfm_machine_macros/Cargo.toml similarity index 100% rename from mfm_machine/mfm_machine_macros/Cargo.toml rename to mfm_machine_derive/mfm_machine_macros/Cargo.toml diff --git a/mfm_machine/mfm_machine_macros/src/lib.rs b/mfm_machine_derive/mfm_machine_macros/src/lib.rs similarity index 100% rename from mfm_machine/mfm_machine_macros/src/lib.rs rename to mfm_machine_derive/mfm_machine_macros/src/lib.rs diff --git a/mfm_machine_derive/src/lib.rs b/mfm_machine_derive/src/lib.rs new file mode 100644 index 0000000..d19ce24 --- /dev/null +++ b/mfm_machine_derive/src/lib.rs @@ -0,0 +1,33 @@ +extern crate proc_macro; + +use proc_macro::TokenStream; +use quote::quote; +use syn::{parse_macro_input, DeriveInput}; + +#[proc_macro_derive(StateMetadataReqs)] +pub fn state_reqs_derive(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let ident = &input.ident; + + let expanded = quote! { + impl StateMetadata for #ident { + fn label(&self) -> Label { + self.label + } + + fn tags(&self) -> Vec { + self.tags.clone() + } + + fn depends_on(&self) -> Vec { + self.depends_on.clone() + } + + fn depends_on_strategy(&self) -> DependencyStrategy { + self.depends_on_strategy + } + } + }; + + TokenStream::from(expanded) +} diff --git a/res/assets/bsc/anonq/abi.json b/res/assets/bsc/anonq/abi.json deleted file mode 100644 index 83eb267..0000000 --- a/res/assets/bsc/anonq/abi.json +++ /dev/null @@ -1,775 +0,0 @@ -[ - { - "inputs":[ - - ], - "stateMutability":"nonpayable", - "type":"constructor" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"owner", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"value", - "type":"uint256" - } - ], - "name":"Approval", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"uint256", - "name":"minTokensBeforeSwap", - "type":"uint256" - } - ], - "name":"MinTokensBeforeSwapUpdated", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"previousOwner", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"newOwner", - "type":"address" - } - ], - "name":"OwnershipTransferred", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"uint256", - "name":"tokensSwapped", - "type":"uint256" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"ethReceived", - "type":"uint256" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"tokensIntoLiquidity", - "type":"uint256" - } - ], - "name":"SwapAndLiquify", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":false, - "internalType":"bool", - "name":"enabled", - "type":"bool" - } - ], - "name":"SwapAndLiquifyEnabledUpdated", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"from", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"to", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"value", - "type":"uint256" - } - ], - "name":"Transfer", - "type":"event" - }, - { - "inputs":[ - - ], - "name":"_liquidityFee", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"_maxTxAmount", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"_taxFee", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"owner", - "type":"address" - }, - { - "internalType":"address", - "name":"spender", - "type":"address" - } - ], - "name":"allowance", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"approve", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"balanceOf", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"decimals", - "outputs":[ - { - "internalType":"uint8", - "name":"", - "type":"uint8" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "internalType":"uint256", - "name":"subtractedValue", - "type":"uint256" - } - ], - "name":"decreaseAllowance", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"tAmount", - "type":"uint256" - } - ], - "name":"deliver", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"excludeFromFee", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"excludeFromReward", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"getUnlockTime", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"includeInFee", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"includeInReward", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "internalType":"uint256", - "name":"addedValue", - "type":"uint256" - } - ], - "name":"increaseAllowance", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"isExcludedFromFee", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"isExcludedFromReward", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"time", - "type":"uint256" - } - ], - "name":"lock", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"name", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"owner", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"pancakePair", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"pancakeRouter", - "outputs":[ - { - "internalType":"contract IPancakeRouter02", - "name":"", - "type":"address" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"tAmount", - "type":"uint256" - }, - { - "internalType":"bool", - "name":"deductTransferFee", - "type":"bool" - } - ], - "name":"reflectionFromToken", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"renounceOwnership", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"rescueBNBFromContract", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"liquidityFee", - "type":"uint256" - } - ], - "name":"setLiquidityFeePercent", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"maxTxPercent", - "type":"uint256" - } - ], - "name":"setMaxTxPercent", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"bool", - "name":"_enabled", - "type":"bool" - } - ], - "name":"setSwapAndLiquifyEnabled", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"taxFee", - "type":"uint256" - } - ], - "name":"setTaxFeePercent", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"swapAndLiquifyEnabled", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"symbol", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"uint256", - "name":"rAmount", - "type":"uint256" - } - ], - "name":"tokenFromReflection", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"totalFees", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"totalSupply", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "stateMutability":"view", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"recipient", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"transfer", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"sender", - "type":"address" - }, - { - "internalType":"address", - "name":"recipient", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"transferFrom", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - { - "internalType":"address", - "name":"newOwner", - "type":"address" - } - ], - "name":"transferOwnership", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "inputs":[ - - ], - "name":"unlock", - "outputs":[ - - ], - "stateMutability":"nonpayable", - "type":"function" - }, - { - "stateMutability":"payable", - "type":"receive" - } -] \ No newline at end of file diff --git a/res/assets/bsc/btcb/abi.json b/res/assets/bsc/btcb/abi.json deleted file mode 100644 index ce84512..0000000 --- a/res/assets/bsc/btcb/abi.json +++ /dev/null @@ -1,293 +0,0 @@ -[ - { - "constant":true, - "inputs":[ - - ], - "name":"name", - "outputs":[ - { - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"guy", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"approve", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"totalSupply", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"src", - "type":"address" - }, - { - "name":"dst", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"transferFrom", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"wad", - "type":"uint256" - } - ], - "name":"withdraw", - "outputs":[ - - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"decimals", - "outputs":[ - { - "name":"", - "type":"uint8" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "name":"", - "type":"address" - } - ], - "name":"balanceOf", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"symbol", - "outputs":[ - { - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"dst", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"transfer", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - - ], - "name":"deposit", - "outputs":[ - - ], - "payable":true, - "stateMutability":"payable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "name":"", - "type":"address" - }, - { - "name":"", - "type":"address" - } - ], - "name":"allowance", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "payable":true, - "stateMutability":"payable", - "type":"fallback" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":true, - "name":"guy", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Approval", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":true, - "name":"dst", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Transfer", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"dst", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Deposit", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Withdrawal", - "type":"event" - } -] \ No newline at end of file diff --git a/res/assets/bsc/busd/abi.json b/res/assets/bsc/busd/abi.json deleted file mode 100644 index 7a67ce9..0000000 --- a/res/assets/bsc/busd/abi.json +++ /dev/null @@ -1,486 +0,0 @@ -[ - { - "inputs":[ - - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"constructor" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"owner", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"value", - "type":"uint256" - } - ], - "name":"Approval", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"previousOwner", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"newOwner", - "type":"address" - } - ], - "name":"OwnershipTransferred", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "internalType":"address", - "name":"from", - "type":"address" - }, - { - "indexed":true, - "internalType":"address", - "name":"to", - "type":"address" - }, - { - "indexed":false, - "internalType":"uint256", - "name":"value", - "type":"uint256" - } - ], - "name":"Transfer", - "type":"event" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"_decimals", - "outputs":[ - { - "internalType":"uint8", - "name":"", - "type":"uint8" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"_name", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"_symbol", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "internalType":"address", - "name":"owner", - "type":"address" - }, - { - "internalType":"address", - "name":"spender", - "type":"address" - } - ], - "name":"allowance", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"approve", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "internalType":"address", - "name":"account", - "type":"address" - } - ], - "name":"balanceOf", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"burn", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"decimals", - "outputs":[ - { - "internalType":"uint8", - "name":"", - "type":"uint8" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "internalType":"uint256", - "name":"subtractedValue", - "type":"uint256" - } - ], - "name":"decreaseAllowance", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"getOwner", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"address", - "name":"spender", - "type":"address" - }, - { - "internalType":"uint256", - "name":"addedValue", - "type":"uint256" - } - ], - "name":"increaseAllowance", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"mint", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"name", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"owner", - "outputs":[ - { - "internalType":"address", - "name":"", - "type":"address" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - - ], - "name":"renounceOwnership", - "outputs":[ - - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"symbol", - "outputs":[ - { - "internalType":"string", - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"totalSupply", - "outputs":[ - { - "internalType":"uint256", - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"address", - "name":"recipient", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"transfer", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"address", - "name":"sender", - "type":"address" - }, - { - "internalType":"address", - "name":"recipient", - "type":"address" - }, - { - "internalType":"uint256", - "name":"amount", - "type":"uint256" - } - ], - "name":"transferFrom", - "outputs":[ - { - "internalType":"bool", - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "internalType":"address", - "name":"newOwner", - "type":"address" - } - ], - "name":"transferOwnership", - "outputs":[ - - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - } -] \ No newline at end of file diff --git a/res/assets/bsc/cake/abi.json b/res/assets/bsc/cake/abi.json deleted file mode 100644 index d1522f4..0000000 --- a/res/assets/bsc/cake/abi.json +++ /dev/null @@ -1,630 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "delegator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "fromDelegate", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "toDelegate", - "type": "address" - } - ], - "name": "DelegateChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "delegate", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "previousBalance", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newBalance", - "type": "uint256" - } - ], - "name": "DelegateVotesChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "DELEGATION_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "DOMAIN_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "name": "checkpoints", - "outputs": [ - { - "internalType": "uint32", - "name": "fromBlock", - "type": "uint32" - }, - { - "internalType": "uint256", - "name": "votes", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegatee", - "type": "address" - } - ], - "name": "delegate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegatee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expiry", - "type": "uint256" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "delegateBySig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "delegator", - "type": "address" - } - ], - "name": "delegates", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "getCurrentVotes", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "blockNumber", - "type": "uint256" - } - ], - "name": "getPriorVotes", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "numCheckpoints", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/res/assets/bsc/eth/abi.json b/res/assets/bsc/eth/abi.json deleted file mode 100644 index ce84512..0000000 --- a/res/assets/bsc/eth/abi.json +++ /dev/null @@ -1,293 +0,0 @@ -[ - { - "constant":true, - "inputs":[ - - ], - "name":"name", - "outputs":[ - { - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"guy", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"approve", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"totalSupply", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"src", - "type":"address" - }, - { - "name":"dst", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"transferFrom", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"wad", - "type":"uint256" - } - ], - "name":"withdraw", - "outputs":[ - - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"decimals", - "outputs":[ - { - "name":"", - "type":"uint8" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "name":"", - "type":"address" - } - ], - "name":"balanceOf", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"symbol", - "outputs":[ - { - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"dst", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"transfer", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - - ], - "name":"deposit", - "outputs":[ - - ], - "payable":true, - "stateMutability":"payable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "name":"", - "type":"address" - }, - { - "name":"", - "type":"address" - } - ], - "name":"allowance", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "payable":true, - "stateMutability":"payable", - "type":"fallback" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":true, - "name":"guy", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Approval", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":true, - "name":"dst", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Transfer", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"dst", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Deposit", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Withdrawal", - "type":"event" - } -] \ No newline at end of file diff --git a/res/assets/bsc/posi/abi.json b/res/assets/bsc/posi/abi.json deleted file mode 100644 index 85813a6..0000000 --- a/res/assets/bsc/posi/abi.json +++ /dev/null @@ -1,906 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousKeeper", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newKeeper", - "type": "address" - } - ], - "name": "BotKeeperChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "Donate", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "previousAmount", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "newAmount", - "type": "uint256" - } - ], - "name": "GenesisRewardChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previusAAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newAddress", - "type": "address" - } - ], - "name": "TreasuryContractChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "inputs": [], - "name": "AIRDROP_AMOUNT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "BASE_MINT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "WHITELIST_SALE_AMOUNT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "aidropDistributed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "botKeeper", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_receivers", - "type": "address[]" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "name": "distributeAirdrop", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "donate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "excludeAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "genesisBalance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "genesisReward", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getCurrentRTSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRate", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "includeAccount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isExcluded", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "isGenesisAddress", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_receiver", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "mint", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "_receivers", - "type": "address[]" - }, - { - "internalType": "uint256", - "name": "_value", - "type": "uint256" - } - ], - "name": "notifyGenesisAddresses", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tAmount", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "deductTransferFee", - "type": "bool" - } - ], - "name": "reflectionFromToken", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "registerAirdropDistribution", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_newKeeper", - "type": "address" - } - ], - "name": "setBotKeeper", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "setGenesisReward", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_isPaused", - "type": "bool" - } - ], - "name": "setTransferStatus", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_newAddress", - "type": "address" - } - ], - "name": "setTreasuryAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "rAmount", - "type": "uint256" - } - ], - "name": "tokenFromReflection", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalFees", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "transferTaxRate", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "treasuryContract", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "recipients", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - } - ], - "name": "treasuryTransfer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "treasuryTransfer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "whitelistSaleDistributed", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] \ No newline at end of file diff --git a/res/assets/bsc/safemoon/abi.json b/res/assets/bsc/safemoon/abi.json deleted file mode 100644 index 97ba944..0000000 --- a/res/assets/bsc/safemoon/abi.json +++ /dev/null @@ -1,678 +0,0 @@ -[{ - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": false, - "internalType": "uint256", - "name": "minTokensBeforeSwap", - "type": "uint256" - }], - "name": "MinTokensBeforeSwapUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": false, - "internalType": "uint256", - "name": "tokensSwapped", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bnbReceived", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "tokensIntoLiquidity", - "type": "uint256" - } - ], - "name": "SwapAndLiquify", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": false, - "internalType": "bool", - "name": "enabled", - "type": "bool" - }], - "name": "SwapAndLiquifyEnabledUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [], - "name": "WBNB", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "_burnAddress", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "_defaultFees", - "outputs": [ - { "internalType": "uint256", "name": "ecoSystemFee", "type": "uint256" }, - { "internalType": "uint256", "name": "liquidityFee", "type": "uint256" }, - { "internalType": "uint256", "name": "taxFee", "type": "uint256" }, - { "internalType": "uint256", "name": "ownerFee", "type": "uint256" }, - { "internalType": "uint256", "name": "burnFee", "type": "uint256" }, - { "internalType": "address", "name": "ecoSystem", "type": "address" }, - { "internalType": "address", "name": "owner", "type": "address" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "_maxTxAmount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_account", "type": "address" } - ], - "name": "accountTier", - "outputs": [{ - "components": [{ - "internalType": "uint256", - "name": "ecoSystemFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidityFee", - "type": "uint256" - }, - { "internalType": "uint256", "name": "taxFee", "type": "uint256" }, - { "internalType": "uint256", "name": "ownerFee", "type": "uint256" }, - { "internalType": "uint256", "name": "burnFee", "type": "uint256" }, - { "internalType": "address", "name": "ecoSystem", "type": "address" }, - { "internalType": "address", "name": "owner", "type": "address" } - ], - "internalType": "struct Safemoon.FeeTier", - "name": "", - "type": "tuple" - }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_ecoSystemFee", "type": "uint256" }, - { "internalType": "uint256", "name": "_liquidityFee", "type": "uint256" }, - { "internalType": "uint256", "name": "_taxFee", "type": "uint256" }, - { "internalType": "uint256", "name": "_ownerFee", "type": "uint256" }, - { "internalType": "uint256", "name": "_burnFee", "type": "uint256" }, - { "internalType": "address", "name": "_ecoSystem", "type": "address" }, - { "internalType": "address", "name": "_owner", "type": "address" } - ], - "name": "addTier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "owner", "type": "address" }, - { "internalType": "address", "name": "spender", "type": "address" } - ], - "name": "allowance", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "spender", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "approve", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "balanceOf", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "blacklistAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "spender", "type": "address" }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "excludeFromFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "excludeFromReward", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_account", "type": "address" } - ], - "name": "excludeWhitelistedAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" } - ], - "name": "feeTier", - "outputs": [{ - "components": [{ - "internalType": "uint256", - "name": "ecoSystemFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "liquidityFee", - "type": "uint256" - }, - { "internalType": "uint256", "name": "taxFee", "type": "uint256" }, - { "internalType": "uint256", "name": "ownerFee", "type": "uint256" }, - { "internalType": "uint256", "name": "burnFee", "type": "uint256" }, - { "internalType": "address", "name": "ecoSystem", "type": "address" }, - { "internalType": "address", "name": "owner", "type": "address" } - ], - "internalType": "struct Safemoon.FeeTier", - "name": "", - "type": "tuple" - }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "feeTiersLength", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "includeInFee", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "includeInReward", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "spender", "type": "address" }, - { "internalType": "uint256", "name": "addedValue", "type": "uint256" } - ], - "name": "increaseAllowance", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_router", "type": "address" } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "isBlacklisted", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "isExcludedFromFee", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "isExcludedFromReward", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "isMigrationStarted", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_account", "type": "address" } - ], - "name": "isWhitelisted", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "migrate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "tAmount", "type": "uint256" }, - { "internalType": "bool", "name": "deductTransferFee", "type": "bool" } - ], - "name": "reflectionFromToken", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "tAmount", "type": "uint256" }, - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "bool", "name": "deductTransferFee", "type": "bool" } - ], - "name": "reflectionFromTokenInTiers", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "uint256", "name": "_burnFee", "type": "uint256" } - ], - "name": "setBurnFeePercent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "setDefaultSettings", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "address", "name": "_ecoSystem", "type": "address" } - ], - "name": "setEcoSystemFeeAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "uint256", "name": "_ecoSystemFee", "type": "uint256" } - ], - "name": "setEcoSystemFeePercent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "uint256", "name": "_liquidityFee", "type": "uint256" } - ], - "name": "setLiquidityFeePercent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "maxTxPercent", "type": "uint256" } - ], - "name": "setMaxTxPercent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_migration", "type": "address" } - ], - "name": "setMigrationAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "address", "name": "_owner", "type": "address" } - ], - "name": "setOwnerFeeAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "uint256", "name": "_ownerFee", "type": "uint256" } - ], - "name": "setOwnerFeePercent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bool", "name": "_enabled", "type": "bool" }], - "name": "setSwapAndLiquifyEnabled", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" }, - { "internalType": "uint256", "name": "_taxFee", "type": "uint256" } - ], - "name": "setTaxFeePercent", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "swapAndLiquifyEnabled", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "rAmount", "type": "uint256" } - ], - "name": "tokenFromReflection", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalFees", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "recipient", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "transfer", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "sender", "type": "address" }, - { "internalType": "address", "name": "recipient", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "transferFrom", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "newOwner", "type": "address" } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "account", "type": "address" } - ], - "name": "unBlacklistAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "uniswapV2Pair", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "uniswapV2Router", - "outputs": [{ - "internalType": "contract IUniswapV2Router02", - "name": "", - "type": "address" - }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ - "internalType": "address", - "name": "_newBurnAddress", - "type": "address" - }], - "name": "updateBurnAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ - "internalType": "address", - "name": "_uniswapV2Router", - "type": "address" - }, - { "internalType": "address", "name": "_uniswapV2Pair", "type": "address" } - ], - "name": "updateRouterAndPair", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_account", "type": "address" }, - { "internalType": "uint256", "name": "_tierIndex", "type": "uint256" } - ], - "name": "whitelistAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { "stateMutability": "payable", "type": "receive" } -] \ No newline at end of file diff --git a/res/assets/bsc/wbnb/abi.json b/res/assets/bsc/wbnb/abi.json deleted file mode 100644 index ce84512..0000000 --- a/res/assets/bsc/wbnb/abi.json +++ /dev/null @@ -1,293 +0,0 @@ -[ - { - "constant":true, - "inputs":[ - - ], - "name":"name", - "outputs":[ - { - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"guy", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"approve", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"totalSupply", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"src", - "type":"address" - }, - { - "name":"dst", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"transferFrom", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"wad", - "type":"uint256" - } - ], - "name":"withdraw", - "outputs":[ - - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"decimals", - "outputs":[ - { - "name":"", - "type":"uint8" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "name":"", - "type":"address" - } - ], - "name":"balanceOf", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":true, - "inputs":[ - - ], - "name":"symbol", - "outputs":[ - { - "name":"", - "type":"string" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "constant":false, - "inputs":[ - { - "name":"dst", - "type":"address" - }, - { - "name":"wad", - "type":"uint256" - } - ], - "name":"transfer", - "outputs":[ - { - "name":"", - "type":"bool" - } - ], - "payable":false, - "stateMutability":"nonpayable", - "type":"function" - }, - { - "constant":false, - "inputs":[ - - ], - "name":"deposit", - "outputs":[ - - ], - "payable":true, - "stateMutability":"payable", - "type":"function" - }, - { - "constant":true, - "inputs":[ - { - "name":"", - "type":"address" - }, - { - "name":"", - "type":"address" - } - ], - "name":"allowance", - "outputs":[ - { - "name":"", - "type":"uint256" - } - ], - "payable":false, - "stateMutability":"view", - "type":"function" - }, - { - "payable":true, - "stateMutability":"payable", - "type":"fallback" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":true, - "name":"guy", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Approval", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":true, - "name":"dst", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Transfer", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"dst", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Deposit", - "type":"event" - }, - { - "anonymous":false, - "inputs":[ - { - "indexed":true, - "name":"src", - "type":"address" - }, - { - "indexed":false, - "name":"wad", - "type":"uint256" - } - ], - "name":"Withdrawal", - "type":"event" - } -] \ No newline at end of file diff --git a/res/assets/erc20_abi.json b/res/assets/erc20_abi.json deleted file mode 100644 index ba877d3..0000000 --- a/res/assets/erc20_abi.json +++ /dev/null @@ -1,279 +0,0 @@ -[ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "guy", - "type": "address" - }, - { - "name": "wad", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "src", - "type": "address" - }, - { - "name": "dst", - "type": "address" - }, - { - "name": "wad", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "wad", - "type": "uint256" - } - ], - "name": "withdraw", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "dst", - "type": "address" - }, - { - "name": "wad", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "deposit", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "address" - }, - { - "name": "", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "src", - "type": "address" - }, - { - "indexed": true, - "name": "guy", - "type": "address" - }, - { - "indexed": false, - "name": "wad", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "src", - "type": "address" - }, - { - "indexed": true, - "name": "dst", - "type": "address" - }, - { - "indexed": false, - "name": "wad", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "dst", - "type": "address" - }, - { - "indexed": false, - "name": "wad", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "src", - "type": "address" - }, - { - "indexed": false, - "name": "wad", - "type": "uint256" - } - ], - "name": "Withdrawal", - "type": "event" - } -] \ No newline at end of file diff --git a/res/exchanges/pancake_swap_v2/abi.json b/res/exchanges/pancake_swap_v2/abi.json deleted file mode 100644 index add5494..0000000 --- a/res/exchanges/pancake_swap_v2/abi.json +++ /dev/null @@ -1,397 +0,0 @@ -[{ - "inputs": [ - { "internalType": "address", "name": "_factory", "type": "address" }, - { "internalType": "address", "name": "_WETH", "type": "address" } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "WETH", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenA", "type": "address" }, - { "internalType": "address", "name": "tokenB", "type": "address" }, - { - "internalType": "uint256", - "name": "amountADesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountBDesired", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, - { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "addLiquidity", - "outputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "amountB", "type": "uint256" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { - "internalType": "uint256", - "name": "amountTokenDesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "addLiquidityETH", - "outputs": [ - { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, - { "internalType": "uint256", "name": "amountETH", "type": "uint256" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "factory", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } - ], - "name": "getAmountIn", - "outputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } - ], - "name": "getAmountOut", - "outputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" } - ], - "name": "getAmountsIn", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" } - ], - "name": "getAmountsOut", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveA", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveB", "type": "uint256" } - ], - "name": "quote", - "outputs": [ - { "internalType": "uint256", "name": "amountB", "type": "uint256" } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenA", "type": "address" }, - { "internalType": "address", "name": "tokenB", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, - { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "removeLiquidity", - "outputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "amountB", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "removeLiquidityETH", - "outputs": [ - { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "removeLiquidityETHSupportingFeeOnTransferTokens", - "outputs": [ - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "bool", "name": "approveMax", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "removeLiquidityETHWithPermit", - "outputs": [ - { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "bool", "name": "approveMax", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", - "outputs": [ - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenA", "type": "address" }, - { "internalType": "address", "name": "tokenB", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, - { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "bool", "name": "approveMax", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "removeLiquidityWithPermit", - "outputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "amountB", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapETHForExactTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactETHForTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForETH", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapTokensForExactETH", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapTokensForExactTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { "stateMutability": "payable", "type": "receive" } -] \ No newline at end of file diff --git a/res/exchanges/pancake_swap_v2/factory_abi.json b/res/exchanges/pancake_swap_v2/factory_abi.json deleted file mode 100644 index 5e8f071..0000000 --- a/res/exchanges/pancake_swap_v2/factory_abi.json +++ /dev/null @@ -1,208 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_feeToSetter", - "type": "address" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "token0", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "token1", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "pair", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "PairCreated", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_CODE_PAIR_HASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "allPairs", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "allPairsLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "tokenB", - "type": "address" - } - ], - "name": "createPair", - "outputs": [ - { - "internalType": "address", - "name": "pair", - "type": "address" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "feeTo", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "feeToSetter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "getPair", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_feeTo", - "type": "address" - } - ], - "name": "setFeeTo", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_feeToSetter", - "type": "address" - } - ], - "name": "setFeeToSetter", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/res/exchanges/uniswap_v2_factory_abi.json b/res/exchanges/uniswap_v2_factory_abi.json deleted file mode 100644 index 5e8f071..0000000 --- a/res/exchanges/uniswap_v2_factory_abi.json +++ /dev/null @@ -1,208 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_feeToSetter", - "type": "address" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "token0", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "token1", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "pair", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "PairCreated", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "INIT_CODE_PAIR_HASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "allPairs", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "allPairsLength", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "tokenB", - "type": "address" - } - ], - "name": "createPair", - "outputs": [ - { - "internalType": "address", - "name": "pair", - "type": "address" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "feeTo", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "feeToSetter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "getPair", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_feeTo", - "type": "address" - } - ], - "name": "setFeeTo", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_feeToSetter", - "type": "address" - } - ], - "name": "setFeeToSetter", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/res/exchanges/uniswap_v2_pair_abi.json b/res/exchanges/uniswap_v2_pair_abi.json deleted file mode 100644 index 6e9b16a..0000000 --- a/res/exchanges/uniswap_v2_pair_abi.json +++ /dev/null @@ -1,454 +0,0 @@ -[{ - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount0", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount1", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - } - ], - "name": "Burn", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount0", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount1", - "type": "uint256" - } - ], - "name": "Mint", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount0In", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount1In", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount0Out", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount1Out", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - } - ], - "name": "Swap", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": false, - "internalType": "uint112", - "name": "reserve0", - "type": "uint112" - }, - { - "indexed": false, - "internalType": "uint112", - "name": "reserve1", - "type": "uint112" - } - ], - "name": "Sync", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MINIMUM_LIQUIDITY", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "internalType": "address", "name": "", "type": "address" }, - { "internalType": "address", "name": "", "type": "address" } - ], - "name": "allowance", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "spender", "type": "address" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "approve", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "balanceOf", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], - "name": "burn", - "outputs": [ - { "internalType": "uint256", "name": "amount0", "type": "uint256" }, - { "internalType": "uint256", "name": "amount1", "type": "uint256" } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "factory", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getReserves", - "outputs": [ - { "internalType": "uint112", "name": "_reserve0", "type": "uint112" }, - { "internalType": "uint112", "name": "_reserve1", "type": "uint112" }, - { - "internalType": "uint32", - "name": "_blockTimestampLast", - "type": "uint32" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "_token0", "type": "address" }, - { "internalType": "address", "name": "_token1", "type": "address" } - ], - "name": "initialize", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "kLast", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], - "name": "mint", - "outputs": [ - { "internalType": "uint256", "name": "liquidity", "type": "uint256" } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "internalType": "address", "name": "", "type": "address" }], - "name": "nonces", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "owner", "type": "address" }, - { "internalType": "address", "name": "spender", "type": "address" }, - { "internalType": "uint256", "name": "value", "type": "uint256" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "permit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "price0CumulativeLast", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "price1CumulativeLast", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "internalType": "address", "name": "to", "type": "address" }], - "name": "skim", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "uint256", "name": "amount0Out", "type": "uint256" }, - { "internalType": "uint256", "name": "amount1Out", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "bytes", "name": "data", "type": "bytes" } - ], - "name": "swap", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [{ "internalType": "string", "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "sync", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "token0", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "token1", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "transfer", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "internalType": "address", "name": "from", "type": "address" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "value", "type": "uint256" } - ], - "name": "transferFrom", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/res/exchanges/uniswap_v2_router_abi.json b/res/exchanges/uniswap_v2_router_abi.json deleted file mode 100644 index add5494..0000000 --- a/res/exchanges/uniswap_v2_router_abi.json +++ /dev/null @@ -1,397 +0,0 @@ -[{ - "inputs": [ - { "internalType": "address", "name": "_factory", "type": "address" }, - { "internalType": "address", "name": "_WETH", "type": "address" } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "WETH", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenA", "type": "address" }, - { "internalType": "address", "name": "tokenB", "type": "address" }, - { - "internalType": "uint256", - "name": "amountADesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountBDesired", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, - { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "addLiquidity", - "outputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "amountB", "type": "uint256" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { - "internalType": "uint256", - "name": "amountTokenDesired", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "addLiquidityETH", - "outputs": [ - { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, - { "internalType": "uint256", "name": "amountETH", "type": "uint256" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "factory", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } - ], - "name": "getAmountIn", - "outputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } - ], - "name": "getAmountOut", - "outputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" } - ], - "name": "getAmountsIn", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" } - ], - "name": "getAmountsOut", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveA", "type": "uint256" }, - { "internalType": "uint256", "name": "reserveB", "type": "uint256" } - ], - "name": "quote", - "outputs": [ - { "internalType": "uint256", "name": "amountB", "type": "uint256" } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenA", "type": "address" }, - { "internalType": "address", "name": "tokenB", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, - { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "removeLiquidity", - "outputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "amountB", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "removeLiquidityETH", - "outputs": [ - { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "removeLiquidityETHSupportingFeeOnTransferTokens", - "outputs": [ - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "bool", "name": "approveMax", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "removeLiquidityETHWithPermit", - "outputs": [ - { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "token", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { - "internalType": "uint256", - "name": "amountTokenMin", - "type": "uint256" - }, - { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "bool", "name": "approveMax", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", - "outputs": [ - { "internalType": "uint256", "name": "amountETH", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenA", "type": "address" }, - { "internalType": "address", "name": "tokenB", "type": "address" }, - { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, - { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, - { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" }, - { "internalType": "bool", "name": "approveMax", "type": "bool" }, - { "internalType": "uint8", "name": "v", "type": "uint8" }, - { "internalType": "bytes32", "name": "r", "type": "bytes32" }, - { "internalType": "bytes32", "name": "s", "type": "bytes32" } - ], - "name": "removeLiquidityWithPermit", - "outputs": [ - { "internalType": "uint256", "name": "amountA", "type": "uint256" }, - { "internalType": "uint256", "name": "amountB", "type": "uint256" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapETHForExactTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactETHForTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForETH", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, - { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapTokensForExactETH", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, - { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, - { "internalType": "address[]", "name": "path", "type": "address[]" }, - { "internalType": "address", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "deadline", "type": "uint256" } - ], - "name": "swapTokensForExactTokens", - "outputs": [ - { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { "stateMutability": "payable", "type": "receive" } -] \ No newline at end of file diff --git a/src/allowance/cmd.rs b/src/allowance/cmd.rs deleted file mode 100644 index c2c4592..0000000 --- a/src/allowance/cmd.rs +++ /dev/null @@ -1,13 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("allowance") - .about("Get allowance for an network and wallet") - .arg(clap::arg!(-n --"network" "Network to use, ex (bsc, polygon)").required(true)) - .arg(clap::arg!(-w --"wallet" "Wallet id from config file").required(true)) -} - -#[tracing::instrument(name = "allowance call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/allowance/mod.rs b/src/allowance/mod.rs deleted file mode 100644 index b091d94..0000000 --- a/src/allowance/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::{cmd::helpers, config::Config, utils}; -use clap::ArgMatches; -use prettytable::{row, table}; - -pub mod cmd; - -#[tracing::instrument(name = "run allowance")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let config = Config::global(); - let mut table = table!(["Exchange", "Asset", "Balance", "Allowance"]); - - let network = helpers::get_network(args)?; - let wallet = helpers::get_wallet(args)?; - - for exchange in network.get_exchanges().into_iter() { - let assets_list = config.assets.assets_by_network(network)?; - - for asset in assets_list.into_iter() { - let balance_of = asset.balance_of(wallet.address()).await?; - let decimals = asset.decimals().await?; - let allowance = asset - .allowance(wallet.address(), exchange.as_router_address().unwrap()) - .await; - - table.add_row(row![ - exchange.name, - asset.name(), - utils::blockchain::display_amount_to_float(balance_of, decimals), - utils::blockchain::display_amount_to_float(allowance, decimals), - ]); - } - } - - table.printstd(); - - Ok(()) -} diff --git a/src/approve/cmd.rs b/src/approve/cmd.rs deleted file mode 100644 index 3c2f753..0000000 --- a/src/approve/cmd.rs +++ /dev/null @@ -1,23 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("approve") - .about("Approve token spending (needed to swap tokens)") - //TODO: add a custom spender arg to add another spenders lide yield-farms - .arg( - clap::arg!(-e --"exchange" "Exchange to use router as spender") - .required(true), - ) - .arg(clap::arg!(-w --"wallet" "Wallet id from config file").required(true)) - .arg(clap::arg!(-a --"asset" "Asset to approve spender").required(true)) - .arg( - clap::arg!(-v --"amount" "Amount to allow spending") - .required(true) - .value_parser(clap::value_parser!(f64)), - ) -} - -#[tracing::instrument(name = "approve call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/approve/mod.rs b/src/approve/mod.rs deleted file mode 100644 index 0103ecc..0000000 --- a/src/approve/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::cmd::helpers; -use clap::ArgMatches; - -pub mod cmd; - -#[tracing::instrument(name = "run approve")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let exchange = helpers::get_exchange(args).unwrap(); - let wallet = helpers::get_wallet(args).unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - let asset = helpers::get_asset_in_network_from_args(args, exchange.network_id()); - - let asset_decimals = asset.decimals().await.unwrap(); - let amount = helpers::get_amount(args, asset_decimals).unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - tracing::debug!("amount: {:?}", amount); - - asset - .approve_spender(wallet, exchange.as_router_address().unwrap(), amount) - .await - .unwrap(); - - let remaning = asset - .allowance(wallet.address(), exchange.as_router_address().unwrap()) - .await; - tracing::debug!( - "approved_spender allowance remaning to spend: {:?}, asset_decimals: {}", - remaning, - asset_decimals - ); - - Ok(()) -} diff --git a/src/approve_all/cmd.rs b/src/approve_all/cmd.rs deleted file mode 100644 index 94ca86f..0000000 --- a/src/approve_all/cmd.rs +++ /dev/null @@ -1,24 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("approve-all") - .about("Approve all configured token spending (needed to swap tokens)") - .arg( - clap::arg!(-w --"wallet" "Wallet id from config file") - .required(true), - ) - .arg( - clap::arg!(-n --"network" "Network to run all approvals") - .required(true), - ) - .arg( - clap::arg!(-a --"amount" "Amount to allow spending: default is the current balance") - .required(false) - .value_parser(clap::value_parser!(f64)), - ) -} - -#[tracing::instrument(name = "approve_all call command", level = "debug")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/approve_all/mod.rs b/src/approve_all/mod.rs deleted file mode 100644 index db4ce10..0000000 --- a/src/approve_all/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -use crate::{cmd::helpers, config::Config}; -use clap::ArgMatches; - -pub mod cmd; - -#[tracing::instrument(name = "run approve-all", skip(args))] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let wallet = helpers::get_wallet(args)?; - let network = helpers::get_network(args)?; - let config = Config::global(); - - let assets = config.assets.assets_by_network(network)?; - let exchanges = network.get_exchanges(); - - for asset in assets { - let asset_decimals = asset.decimals().await.unwrap(); - let amount = helpers::get_amount(args, asset_decimals).unwrap_or(asset.balance_of(wallet.address()).await?); - tracing::debug!("amount: {:?}", amount); - - for exchange in exchanges.iter() { - let allowance_amount = asset.allowance(wallet.address(), exchange.as_router_address().unwrap()).await; - if allowance_amount >= amount { - tracing::info!("current amount allowed is greater or equal --amount, to {} on {} for {} with spender {}", asset.name(), exchange.name(), amount, wallet.address()); - continue; - } - - tracing::info!("running approve_spender to {} on {} for {} with spender {}", asset.name(), exchange.name(), amount, wallet.address()); - asset - .approve_spender(wallet, exchange.as_router_address().unwrap(), amount) - .await - .unwrap(); - - let remaning = asset - .allowance(wallet.address(), exchange.as_router_address().unwrap()) - .await; - tracing::info!( - "approved_spender allowance remaning on {}, to spend: {:?}, asset_decimals: {}", - asset.name(), - remaning, - asset_decimals - ); - } - } - Ok(()) -} diff --git a/src/asset/config.rs b/src/asset/config.rs deleted file mode 100644 index 9634ce4..0000000 --- a/src/asset/config.rs +++ /dev/null @@ -1,89 +0,0 @@ -use super::Asset; -use crate::config::{network::Network, Config}; -use anyhow::Context; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct AssetNetwork { - pub(crate) name: String, - pub(crate) network_id: String, - pub(crate) address: String, - pub(crate) slippage: f64, - pub(crate) path_asset: String, -} - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct AssetNetworks(HashMap); - -impl AssetNetworks { - pub fn get(&self, key: &str) -> Result<&AssetNetwork, anyhow::Error> { - self.0.get(key).context("network doesnt exist for asset") - } - pub fn hashmap(&self) -> &HashMap { - &self.0 - } -} - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct AssetConfig { - pub(crate) kind: String, - pub(crate) networks: AssetNetworks, -} - -impl AssetConfig { - pub fn assets_list_by_network(&self) -> Result, anyhow::Error> { - self.networks - .hashmap() - .values() - .map(|a| { - let network = Config::global() - .networks - .get(&a.network_id) - .context("network not found")?; - Asset::new(self, network) - }) - .collect() - } -} - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct AssetsConfig(HashMap); -impl AssetsConfig { - pub fn hashmap(&self) -> &HashMap { - &self.0 - } - - pub fn get(&self, key: &str) -> Option<&AssetConfig> { - self.0.get(key) - } - - //TODO: use this function to get assets of the current network - pub fn assets_by_network(&self, network: &Network) -> Result, anyhow::Error> { - let assets_config = self - .0 - .values() - .filter(|&a| a.networks.get(network.name()).is_ok()); - - assets_config.map(|ac| Asset::new(ac, network)).collect() - } - - //TODO: use this function to get assets of the current network - pub fn find_by_name_and_network( - &self, - name: &str, - network: &str, - ) -> Result { - let config = Config::global(); - let asset_config = self - .get(name) - .context(format!("asset_config not found, key: {}", name))?; - - let network = config - .networks - .get(network) - .context(format!("network not found, key: {}", network))?; - - Asset::new(asset_config, network) - } -} diff --git a/src/asset/mod.rs b/src/asset/mod.rs deleted file mode 100644 index 745ebb3..0000000 --- a/src/asset/mod.rs +++ /dev/null @@ -1,401 +0,0 @@ -use rustc_hex::FromHexError; -use serde::{Deserialize, Serialize}; -use std::str::FromStr; -use web3::ethabi::Token; -use web3::Web3; -use web3::{ - contract::{Contract, Options}, - transports::Http, - types::{Address, Bytes, H160, U256}, -}; - -use crate::utils::{self, math}; - -use crate::config::{network::Network, wallet::Wallet, withdraw_wallet::WithdrawWallet, Config}; -use crate::utils::resources::{exists_resource_file_fs_or_res, get_resource_file_fs_or_res}; -use config::AssetConfig; - -pub mod config; - -const FALLBACK_ABI_PATH: &str = "res/assets/erc20_abi.json"; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Asset { - name: String, - kind: String, - network_id: String, - address: String, - slippage: f64, - path_asset: String, - network: Network, -} - -impl Asset { - pub fn new(asset_config: &AssetConfig, network: &Network) -> Result { - let asset_network = asset_config.networks.get(network.name())?; - - // TODO: add a validator for the builders - - if !(asset_network.slippage > 0.0 && asset_network.slippage <= 100.0) { - return Err(anyhow::anyhow!( - "Asset::new(): asset_name: {}; slippage needs to be between 0 and 100", - asset_network.name - )); - } - - Ok(Asset { - name: asset_network.name.clone(), - kind: asset_config.kind.clone(), - network_id: asset_network.network_id.clone(), - address: asset_network.address.clone(), - slippage: asset_network.slippage, - path_asset: asset_network.path_asset.clone(), - network: (*network).clone(), - }) - } - - pub fn slippage(&self) -> f64 { - self.slippage - } - - pub fn slippage_u256(&self, asset_decimals: u8) -> U256 { - math::percent_to_u256(self.slippage, asset_decimals) - } - - pub fn name(&self) -> &str { - &self.name - } - - pub fn address(&self) -> &str { - self.address.as_str() - } - - pub fn as_address(&self) -> Result { - Address::from_str(self.address()) - } - - pub fn network_id(&self) -> &str { - self.network_id.as_str() - } - - pub fn get_path_asset(&self) -> Asset { - Config::global() - .assets - .find_by_name_and_network(self.path_asset.as_str(), self.network_id.as_str()) - .unwrap() - } - - pub fn abi_path(&self) -> String { - let path = format!( - "res/assets/{}/{}/abi.json", - self.network_id.as_str(), - self.name.as_str() - ); - - if exists_resource_file_fs_or_res(path.as_str()) { - return path; - } - FALLBACK_ABI_PATH.to_string() - } - - pub fn abi_json_string(&self) -> String { - let file_string = get_resource_file_fs_or_res(self.abi_path()).unwrap(); - let json: serde_json::Value = serde_json::from_str(file_string.as_str()).unwrap(); - json.to_string() - } - - pub fn get_network(&self) -> &Network { - &self.network - } - - pub fn get_web3_client_http(&self) -> Web3 { - self.get_network().get_web3_client_rpc() - } - - pub fn contract(&self) -> Contract { - let client = self.get_web3_client_http(); - let contract_address = self.as_address().unwrap(); - let json_abi = self.abi_json_string(); - Contract::from_json(client.eth(), contract_address, json_abi.as_bytes()).unwrap() - } - - // TODO: validate it in the initialization of Asset - #[tracing::instrument(name = "get decimals from asset contract", level = "debug")] - pub async fn decimals(&self) -> Result { - self.contract() - .query("decimals", (), None, Options::default(), None) - .await - .map_err(|e| anyhow::anyhow!("failed to fetch gas_price, got: {:?}", e)) - } - - pub async fn balance_of(&self, account: H160) -> Result { - let contract = &self.contract(); - contract - .query("balanceOf", (account,), None, Options::default(), None) - .await - .map_err(|e| anyhow::anyhow!("failed to fetch balance, got: {:?}", e)) - } - - pub fn build_path_for_coin(&self, coin_address: H160) -> Vec { - vec![coin_address, self.as_address().unwrap()] - } - - pub async fn balance_of_quoted_in( - &self, - wallet: &Wallet, - quoted: &Asset, - ) -> Result { - let account = wallet.address(); - let base_balance = self.balance_of(account).await?; - let exchange = self - .get_network() - .get_exchange_by_liquidity(self, quoted, base_balance) - .await.unwrap_or_else(||{ - tracing::error!( - "Asset::balance_of_quoted_in(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - self, - quoted - ); - panic!() - }); - - if self.name() == quoted.name() { - return Ok(base_balance); - } - - let assets_path = exchange.build_route_for(self, quoted).await; - - Ok(exchange - .get_amounts_out(base_balance, assets_path) - .await - .last() - .unwrap() - .into()) - } - - pub fn exist_max_tx_amount(&self) -> bool { - self.contract().abi().function("_maxTxAmount").is_ok() - } - - pub async fn max_tx_amount(&self) -> Option { - if !self.exist_max_tx_amount() { - return None; - } - - match self - .contract() - .query("_maxTxAmount", (), None, Options::default(), None) - .await - { - Ok(m) => Some(m), - _ => None, - } - } - - pub async fn allowance(&self, owner: H160, spender: H160) -> U256 { - let result: U256 = self - .contract() - .query( - "allowance", - (owner, spender), - None, - Options::default(), - None, - ) - .await - .unwrap(); - result - } - - pub async fn approve_spender( - &self, - from_wallet: &Wallet, - spender: H160, - amount: U256, - ) -> Result<(), anyhow::Error> { - let client = self.get_web3_client_http(); - let gas_price = client.eth().gas_price().await.unwrap(); - - let estimate_gas = utils::blockchain::estimate_gas( - &self.contract(), - from_wallet, - "approve", - (spender, amount), - web3::contract::Options { - gas_price: Some(gas_price), - ..Default::default() - }, - ) - .await?; - - tracing::debug!("approve_spender called estimate_gas: {:?}", estimate_gas); - - let func_data = utils::blockchain::generate_func_data( - &self.contract(), - "approve", - &[Token::Address(spender), Token::Uint(amount)], - )?; - tracing::debug!("approve_spender(): func_data: {:?}", func_data); - - let nonce = from_wallet.nonce(client.clone()).await.unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - tracing::debug!("approve_spender(): nonce: {:?}", nonce); - - let transaction_obj = utils::blockchain::build_transaction_params( - nonce, - self.as_address().unwrap(), - U256::from(0_i32), - gas_price, - estimate_gas, - Bytes(func_data), - ); - tracing::debug!("approve_spender(): transaction_obj: {:?}", transaction_obj); - - utils::blockchain::sign_send_and_wait_txn(client.clone(), transaction_obj, from_wallet) - .await?; - - Ok(()) - } - - pub async fn unwrap(&self, from_wallet: &Wallet, amount: U256) -> Result<(), anyhow::Error> { - let client = self.get_web3_client_http(); - let gas_price = client.eth().gas_price().await.unwrap(); - - let estimate_gas = utils::blockchain::estimate_gas( - &self.contract(), - from_wallet, - "withdraw", - (amount,), - web3::contract::Options { - gas_price: Some(gas_price), - ..Default::default() - }, - ) - .await?; - tracing::debug!("unwrap called estimate_gas: {:?}", estimate_gas); - - let func_data = utils::blockchain::generate_func_data( - &self.contract(), - "withdraw", - &[Token::Uint(amount)], - )?; - tracing::debug!("unwrap(): deposit_data: {:?}", func_data); - - let nonce = from_wallet.nonce(client.clone()).await.unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - tracing::debug!("unwrap(): nonce: {:?}", nonce); - - let transaction_obj = utils::blockchain::build_transaction_params( - nonce, - self.as_address().unwrap(), - U256::from(0_i32), - gas_price, - estimate_gas, - Bytes(func_data), - ); - tracing::debug!("unwrap(): transaction_obj: {:?}", transaction_obj); - - utils::blockchain::sign_send_and_wait_txn(client.clone(), transaction_obj, from_wallet) - .await?; - - Ok(()) - } - - pub async fn wrap(&self, from_wallet: &Wallet, amount: U256) -> Result<(), anyhow::Error> { - let client = self.get_web3_client_http(); - let gas_price = client - .eth() - .gas_price() - .await - .map_err(|e| anyhow::anyhow!("failed to fetch gas_price, got: {:?}", e))?; - - let estimate_gas = utils::blockchain::estimate_gas( - &self.contract(), - from_wallet, - "deposit", - (), - web3::contract::Options { - value: Some(amount), - gas_price: Some(gas_price), - ..Default::default() - }, - ) - .await?; - tracing::debug!("wrap called estimate_gas: {:?}", estimate_gas); - - let func_data = utils::blockchain::generate_func_data(&self.contract(), "deposit", &[])?; - tracing::debug!("wrap(): deposit_data: {:?}", func_data); - - let nonce = from_wallet.nonce(client.clone()).await?; - tracing::debug!("wrap(): nonce: {:?}", nonce); - - let transaction_obj = utils::blockchain::build_transaction_params( - nonce, - self.as_address().unwrap(), - amount, - gas_price, - estimate_gas, - Bytes(func_data), - ); - tracing::debug!("wrap(): transaction_obj: {:?}", transaction_obj); - - utils::blockchain::sign_send_and_wait_txn(client.clone(), transaction_obj, from_wallet) - .await?; - - Ok(()) - } - - pub async fn withdraw( - &self, - wallet: &Wallet, - withdraw_wallet: &WithdrawWallet, - amount: U256, - ) -> Result<(), anyhow::Error> { - let client = self.get_web3_client_http(); - let gas_price = client.eth().gas_price().await.unwrap(); - - let estimate_gas = utils::blockchain::estimate_gas( - &self.contract(), - wallet, - "transfer", - (withdraw_wallet.as_address(), amount), - web3::contract::Options { - gas_price: Some(gas_price), - ..Default::default() - }, - ) - .await?; - tracing::debug!("withdraw called estimate_gas: {:?}", estimate_gas); - - let func_data = utils::blockchain::generate_func_data( - &self.contract(), - "transfer", - &[ - Token::Address(withdraw_wallet.as_address()), - Token::Uint(amount), - ], - )?; - tracing::debug!("withdraw(): func_data: {:?}", func_data); - - let nonce = wallet.nonce(client.clone()).await?; - tracing::debug!("withdraw(): nonce: {:?}", nonce); - - let transaction_obj = utils::blockchain::build_transaction_params( - nonce, - self.as_address().unwrap(), - U256::from(0_i32), - gas_price, - estimate_gas, - Bytes(func_data), - ); - tracing::debug!("withdraw(): transaction_obj: {:?}", transaction_obj); - - utils::blockchain::sign_send_and_wait_txn(client.clone(), transaction_obj, wallet).await?; - - Ok(()) - } -} diff --git a/src/balances/cmd.rs b/src/balances/cmd.rs deleted file mode 100644 index 6b73bb8..0000000 --- a/src/balances/cmd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use clap::{ArgMatches, Command}; - -// TODO: refactor flagable args for the command like hide-zero to use arg.get_flag() -pub fn generate() -> Command { - Command::new("balances") - .about("Check balances from all assets listed on config") - .arg(clap::arg!(-w --"wallet" "Wallet id from config file").required(true)) - .arg( - clap::arg!(-z --"hide-zero" "hide zero balances") - .required(false) - .default_value("false"), - ) -} - -#[tracing::instrument(name = "balances call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/balances/mod.rs b/src/balances/mod.rs deleted file mode 100644 index e80206c..0000000 --- a/src/balances/mod.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::config::Config; -use crate::{cmd::helpers, utils}; -use clap::ArgMatches; -use prettytable::{row, table}; -use web3::types::U256; - -pub mod cmd; - -#[tracing::instrument(name = "run balances")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let config = Config::global(); - let wallet = helpers::get_wallet(args)?; - let hide_zero = helpers::get_hide_zero(args); - - let mut table = table!([ - "Network", - "Asset", - "Balance in float", - "Balance", - "Decimals" - ]); - - let networks = config.networks.hashmap().values(); - - for network in networks.clone() { - let network_name = network.name(); - let symbol = network.symbol(); - let decimals = network.coin_decimals(); - let balance_of = network.balance_coin(wallet).await?; - if !(hide_zero && balance_of == U256::from(0_i32)) { - table.add_row(row![ - network_name, - symbol, - utils::blockchain::display_amount_to_float(balance_of, decimals), - balance_of, - decimals - ]); - } - } - - for network in networks.clone() { - let assets_list = config.assets.assets_by_network(network)?; - for asset in assets_list.into_iter() { - let balance_of = asset.balance_of(wallet.address()).await?; - let decimals = asset.decimals().await?; - if !(hide_zero && balance_of == U256::from(0_i32)) { - table.add_row(row![ - asset.network_id(), - asset.name(), - utils::blockchain::display_amount_to_float(balance_of, decimals), - balance_of, - decimals - ]); - } - } - } - - table.printstd(); - Ok(()) -} diff --git a/src/cmd/enc.rs b/src/cmd/enc.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/cmd/helpers.rs b/src/cmd/helpers.rs deleted file mode 100644 index b9323f7..0000000 --- a/src/cmd/helpers.rs +++ /dev/null @@ -1,259 +0,0 @@ -use std::str::FromStr; - -use crate::{ - asset::Asset, - config::{ - exchange::Exchange, network::Network, wallet::Wallet, withdraw_wallet::WithdrawWallet, - Config, - }, - rebalancer::config::RebalancerConfig, - utils::math, -}; -use anyhow::Context; -use clap::ArgMatches; -use web3::types::{Address, H160, U256}; - -//TODO: add constants to all keys in value_of - -#[tracing::instrument(name = "get exchange from command args", level = "debug", skip(args))] -pub fn get_exchange(args: &ArgMatches) -> Result<&Exchange, anyhow::Error> { - match args.get_one::("exchange") { - Some(n) => { - let network = Config::global() - .exchanges - .get(n) - .context("exchange not found")?; - Ok(network) - } - None => Err(anyhow::anyhow!("--exchange is required")), - } -} - -#[tracing::instrument(name = "get network from command args", level = "debug", skip(args))] -pub fn get_network(args: &ArgMatches) -> Result<&Network, anyhow::Error> { - match args.get_one::("network") { - Some(n) => { - let network = Config::global() - .networks - .get(n) - .context("network not found")?; - Ok(network) - } - None => Err(anyhow::anyhow!("--network is required")), - } -} - -#[tracing::instrument(name = "get address from command args", level = "debug", skip(args))] -pub fn get_address(args: &ArgMatches) -> Result { - match args.get_one::("address") { - Some(a) => Address::from_str(a).map_err(|e| anyhow::anyhow!(e)), - None => Err(anyhow::anyhow!("--address is required")), - } -} - -#[tracing::instrument(name = "get wallet from command args", level = "debug", skip(args))] -pub fn get_wallet(args: &ArgMatches) -> Result<&Wallet, anyhow::Error> { - let config = Config::global(); - match args.get_one::("wallet") { - Some(n) => { - let wallet = config.wallets.get(n).context("wallet not found")?; - Ok(wallet) - } - None => Err(anyhow::anyhow!("--wallet is required")), - } -} - -pub fn get_asset_in_network_from_args(args: &ArgMatches, network_id: &str) -> Asset { - match args.get_one::("asset") { - Some(a) => Config::global() - .assets - .find_by_name_and_network(a, network_id) - .unwrap(), - None => panic!("--asset not supported"), - } -} - -pub fn get_quoted_asset_in_network_from_args( - args: &ArgMatches, - network_id: &str, -) -> Result { - let config = Config::global(); - match args.get_one::("quoted-asset") { - Some(a) => config.assets.find_by_name_and_network(a, network_id), - None => Err(anyhow::anyhow!("--quoted-asset is required")), - } -} - -pub fn get_force_harvest(args: &ArgMatches) -> bool { - match args.get_one::("force-harvest") { - Some(a) => *a, - None => panic!("--force-harvest supported"), - } -} - -pub fn get_txn_id(args: &ArgMatches) -> &str { - match args.get_one::("txn_id") { - Some(a) => a, - None => panic!("--txn_id not supported"), - } -} - -#[tracing::instrument(name = "get amount from command args", skip(args), level = "debug")] -pub fn get_amount(args: &ArgMatches, asset_decimals: u8) -> Result { - match args.get_one::("amount") { - Some(amount) => Ok(math::f64_to_u256(*amount, asset_decimals)), - None => Err(anyhow::anyhow!("--amount is not a number")), - } -} - -#[tracing::instrument(name = "get amount in f64 from command args", level = "debug", skip(args))] -pub fn get_amount_f64(args: &ArgMatches) -> Result { - match args.get_one::("amount") { - Some(amount) => Ok(*amount), - None => Err(anyhow::anyhow!("--amount is not a number")), - } -} - -#[tracing::instrument(name = "get slippage in f64 from command args", level = "debug", skip(args))] -pub fn get_slippage(args: &ArgMatches) -> Result { - match args.get_one::("slippage") { - Some(f) if *f > 0.0 && *f <= 100.0 => Ok(*f), - Some(f) => Err(anyhow::anyhow!( - "--slippage needs to be between 0 and 100. f: {}", - f - )), - None => Err(anyhow::anyhow!("--slippage is not a number")), - } -} - -#[tracing::instrument(name = "get input token in network from command args", level = "debug", skip(args))] -pub fn get_token_input_in_network_from_args( - args: &ArgMatches, - network_id: &str, -) -> Result { - match args.get_one::("token_input") { - Some(i) => Config::global() - .assets - .find_by_name_and_network(i, network_id), - None => Err(anyhow::anyhow!( - "--token_input not supported on current network" - )), - } -} - -#[tracing::instrument(name = "get output token in network from command args", level = "debug", skip(args))] -pub fn get_token_output_in_network_from_args( - args: &ArgMatches, - network_id: &str, -) -> Result { - match args.get_one::("token_output") { - Some(i) => Config::global() - .assets - .find_by_name_and_network(i, network_id), - None => Err(anyhow::anyhow!( - "--token_output not supported on current network" - )), - } -} - -pub fn get_rebalancer(args: &ArgMatches) -> RebalancerConfig { - let config = Config::global(); - match args.get_one::("name") { - Some(i) => match config.rebalancers.clone() { - Some(rebalancers) => rebalancers.get(i).clone(), - None => { - tracing::error!("get_rebalancer() rebalancers is not configured"); - panic!() - } - }, - None => panic!("--name not supported"), - } -} - -pub fn get_withdraw_wallet(args: &ArgMatches) -> WithdrawWallet { - let config = Config::global(); - match args.get_one::("withdraw-wallet") { - Some(w) => match config.withdraw_wallets.clone() { - Some(withdraw_wallets) => withdraw_wallets.get(w).clone(), - None => { - tracing::error!("get_withdraw_wallet() withdraw_wallet is not configured"); - panic!() - } - }, - None => panic!("--withdraw-wallet not supported"), - } -} - -#[tracing::instrument(name = "get hide zero from command args", level = "debug", skip(args))] -pub fn get_hide_zero(args: &ArgMatches) -> bool { - match args.get_one::("hide-zero") { - Some(b) => b.parse().unwrap_or(false), - _ => false, - } -} - -#[tracing::instrument(name = "get run every from command args", level = "debug", skip(args))] -pub fn get_run_every(args: &ArgMatches) -> Option<&u32> { - args.get_one::("run-every") -} - -#[tracing::instrument(name = "get track from command args", level = "debug", skip(args))] -pub fn get_track(args: &ArgMatches) -> bool { - match args.get_one::("track") { - Some(b) => b.parse().unwrap_or(false), - _ => false, - } -} - -mod test { - use clap::{ArgMatches, Command}; - - fn _get_arg_matches(cmd: Command, argv: &'static str) -> ArgMatches { - cmd.try_get_matches_from(argv.split(' ').collect::>()) - .unwrap() - } - - #[test] - fn get_hide_zero_working() { - use super::get_hide_zero; - - let cmd = Command::new("app").arg( - clap::arg!(-z --"hide-zero" "hide zero balances") - .required(false) - .default_value("false"), - ); - - let test_cases = [ - ("app --hide-zero=true", true), - ("app --hide-zero=false", false), - ("app --hide-zero=invalid-false", false), - ]; - - for (argv, expected) in test_cases { - let arg_matches = _get_arg_matches(cmd.clone(), argv); - assert_eq!(get_hide_zero(&arg_matches), expected); - } - } - - #[test] - fn get_network_working() { - use super::get_network; - use crate::config::Config; - - Config::from_file("test_config.yaml").unwrap(); - - let cmd = Command::new("app") - .arg(clap::arg!(-n --"network" "Network to wrap coin to token").required(true)); - - let test_cases = [ - ("app --network=bsc", true), - ("app --network=false", false), - ("app --network=invalid-false", false), - ]; - - for (argv, expected) in test_cases { - let arg_matches = _get_arg_matches(cmd.clone(), argv); - assert_eq!(get_network(&arg_matches).is_ok(), expected); - } - } -} diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs deleted file mode 100644 index 1e0f5c3..0000000 --- a/src/cmd/mod.rs +++ /dev/null @@ -1,101 +0,0 @@ -use crate::{ - allowance, approve, balances, encrypt, quote, rebalancer, swap, track, unwrap, withdraw, wrap, watcher, approve_all, -}; -use crate::{config::Config, APP_NAME}; -use clap::{crate_version, ArgMatches, Command}; -use serde::{Deserialize, Serialize}; - -pub mod helpers; - -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum Commands { - Balances, - Wrap, - Unwrap, - Swap, - Allowance, - Approve, - Rebalancer, - Withdraw, - Quote, - Track, - Encrypt, - Watcher, - #[serde(rename = "approve-all")] - ApproveAll, -} - -impl Commands { - pub async fn run(&self, args: &ArgMatches) -> Result<(), anyhow::Error> { - match &self { - Self::Balances => balances::cmd::call_sub_commands(args).await, - Self::Wrap => wrap::cmd::call_sub_commands(args).await, - Self::Unwrap => unwrap::cmd::call_sub_commands(args).await, - Self::Swap => swap::cmd::call_sub_commands(args).await, - Self::Allowance => allowance::cmd::call_sub_commands(args).await, - Self::Approve => approve::cmd::call_sub_commands(args).await, - Self::Rebalancer => rebalancer::cmd::call_sub_commands(args).await, - Self::Withdraw => withdraw::cmd::call_sub_commands(args).await, - Self::Encrypt => encrypt::cmd::call_sub_commands(args).await, - Self::Quote => quote::cmd::call_sub_commands(args).await, - Self::Track => track::cmd::call_sub_commands(args).await, - Self::Watcher => watcher::cmd::call_sub_commands(args).await, - Self::ApproveAll => approve_all::cmd::call_sub_commands(args).await, - } - } -} - -pub fn new() -> Command { - Command::new(APP_NAME) - .bin_name(APP_NAME) - .version(crate_version!()) - .arg( - clap::arg!(-c - -config_filename "Config file path") - .required(false) - .default_value("config.yaml"), - ) - .subcommand_required(true) - .subcommand(wrap::cmd::generate()) - .subcommand(unwrap::cmd::generate()) - .subcommand(swap::cmd::generate()) - .subcommand(allowance::cmd::generate()) - .subcommand(approve::cmd::generate()) - .subcommand(balances::cmd::generate()) - .subcommand(rebalancer::cmd::generate()) - .subcommand(encrypt::cmd::generate()) - .subcommand(withdraw::cmd::generate()) - .subcommand(quote::cmd::generate()) - .subcommand(track::cmd::generate()) - .subcommand(watcher::cmd::generate()) - .subcommand(approve_all::cmd::generate()) -} - -#[tracing::instrument(name = "lookup command from cli", level = "debug")] -pub fn lookup_command(cmd: &str) -> Result { - let json_cmd = format!("\"{}\"", cmd); - serde_json::from_str(json_cmd.as_str()).map_err(|e| anyhow::anyhow!(e)) -} - -#[tracing::instrument(name = "call commands", level = "debug")] -pub async fn call_sub_commands(matches: &ArgMatches) -> Result<(), anyhow::Error> { - match matches.subcommand() { - Some((cmd, sub_matches)) => lookup_command(cmd)?.run(sub_matches).await, - _ => Err(anyhow::anyhow!("subcommand is required")), - } -} - -#[tracing::instrument(name = "cli run command", level = "debug")] -pub async fn run(cmd: Command) -> Result<(), anyhow::Error> { - let cmd_matches = cmd.get_matches(); - - match cmd_matches.get_one::("config_filename") { - Some(f) => Config::from_file(f)?, - None => return Err(anyhow::anyhow!("--config_filename is invalid")), - }; - - call_sub_commands(&cmd_matches).await.map_err(|e| { - tracing::error!(error = %e); - anyhow::anyhow!("call subcommand failed, err: {}", e) - }) -} diff --git a/src/config/decrypt_wallet.rs b/src/config/decrypt_wallet.rs deleted file mode 100644 index 7fa741a..0000000 --- a/src/config/decrypt_wallet.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::utils::password::{decrypt_private_key, get_or_prompt_password}; - -use super::{wallet::Wallets, Config}; - -// TODO: refactor this mutable config when we have wallets as a mod with config and build types -pub fn decrypt_wallets_from_config(c: Config) -> Config { - let mut config = c; - let mut wallets = config.wallets.hashmap().clone(); - for (k, wallet) in config - .wallets - .hashmap() - .iter() - .filter(|(_, v)| v.encrypted.unwrap_or(false)) - { - let mut n_wallet = wallet.clone(); - let decrypted = { - let password = get_or_prompt_password(wallet.env_password.clone()).unwrap(); - decrypt_private_key(password, wallet.private_key.clone()).unwrap() - }; - n_wallet.private_key = decrypted; - wallets.insert(k.clone(), n_wallet); - } - config.wallets = Wallets(wallets); - config -} diff --git a/src/config/exchange.rs b/src/config/exchange.rs deleted file mode 100644 index 729b0c8..0000000 --- a/src/config/exchange.rs +++ /dev/null @@ -1,497 +0,0 @@ -use crate::asset::Asset; -use crate::utils::resources::{exists_resource_file_fs_or_res, get_resource_file_fs_or_res}; -use crate::utils::scalar::BigDecimal; -use crate::utils::{self, math}; - -use std::ops::Div; -use std::str::FromStr; -use std::time::UNIX_EPOCH; -use std::{collections::HashMap, time::SystemTime}; - -use rustc_hex::FromHexError; -use serde::{Deserialize, Serialize}; -use web3::Web3; -use web3::{ - contract::{Contract, Options}, - ethabi::Token, - transports::Http, - types::{Address, H160, U256}, -}; - -use super::network::Network; -use super::wallet::Wallet; -use super::Config; - -pub mod swap_eth_for_tokens; -pub mod swap_tokens_for_tokens; - -pub const ZERO_ADDRESS: &str = "0x0000000000000000000000000000000000000000"; -const FALLBACK_FACTORY_ABI_PATH: &str = "res/exchanges/uniswap_v2_factory_abi.json"; -const FALLBACK_PAIR_ABI_PATH: &str = "res/exchanges/uniswap_v2_pair_abi.json"; -const FALLBACK_ROUTER_ABI_PATH: &str = "res/exchanges/uniswap_v2_router_abi.json"; - -//TODO: validate the fields in the new mod initialization -// do it building a new type using a ExchangeConfig -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct Exchange { - pub(crate) name: String, - pub(crate) router_address: String, - pub(crate) factory_address: String, - pub(crate) network_id: String, -} - -impl Exchange { - pub fn name(&self) -> &str { - self.name.as_str() - } - - pub fn network_id(&self) -> &str { - self.network_id.as_str() - } - - pub fn router_address(&self) -> &str { - self.router_address.as_str() - } - - pub fn factory_address(&self) -> &str { - self.router_address.as_str() - } - - pub fn as_router_address(&self) -> Result { - Address::from_str(self.factory_address()) - } - - pub fn as_factory_address(&self) -> H160 { - Address::from_str(self.factory_address()).unwrap() - } - - pub fn router_abi_path(&self) -> String { - let path = format!("res/exchanges/{}/abi.json", self.name.as_str()); - if exists_resource_file_fs_or_res(path.as_str()) { - return path; - } - FALLBACK_ROUTER_ABI_PATH.to_string() - } - - pub fn router_abi_json_string(&self) -> String { - let file_string = get_resource_file_fs_or_res(self.router_abi_path()).unwrap(); - let json: serde_json::Value = serde_json::from_str(file_string.as_str()).unwrap(); - json.to_string() - } - - pub fn factory_abi_path(&self) -> String { - let path = format!("res/exchanges/{}/factory_abi.json", self.name.as_str()); - if exists_resource_file_fs_or_res(path.as_str()) { - return path; - } - FALLBACK_FACTORY_ABI_PATH.to_string() - } - - pub fn factory_abi_json_string(&self) -> String { - let file_string = get_resource_file_fs_or_res(self.factory_abi_path()).unwrap(); - let json: serde_json::Value = serde_json::from_str(file_string.as_str()).unwrap(); - json.to_string() - } - - pub fn pair_abi_path(&self) -> String { - let path = format!("res/exchanges/{}/pair_abi.json", self.name.as_str()); - if exists_resource_file_fs_or_res(path.as_str()) { - return path; - } - FALLBACK_PAIR_ABI_PATH.to_string() - } - - pub fn pair_abi_json_string(&self) -> String { - let file_string = get_resource_file_fs_or_res(self.pair_abi_path()).unwrap(); - let json: serde_json::Value = serde_json::from_str(file_string.as_str()).unwrap(); - json.to_string() - } - - pub fn router_contract(&self) -> Contract { - let client = self.get_web3_client_http(); - let contract_address = self.as_router_address().unwrap(); - let json_abi = self.router_abi_json_string(); - Contract::from_json(client.eth(), contract_address, json_abi.as_bytes()).unwrap() - } - - pub fn factory_contract(&self) -> Contract { - let client = self.get_web3_client_http(); - let contract_address = self.as_factory_address(); - let json_abi = self.factory_abi_json_string(); - Contract::from_json(client.eth(), contract_address, json_abi.as_bytes()).unwrap() - } - - pub fn pair_contract(&self, contract_address: H160) -> Contract { - let client = self.get_web3_client_http(); - let json_abi = self.pair_abi_json_string(); - Contract::from_json(client.eth(), contract_address, json_abi.as_bytes()).unwrap() - } - - pub async fn wrapper_address(&self) -> H160 { - let router_contract = self.router_contract(); - - router_contract - .query("WETH", (), None, Options::default(), None) - .await - .unwrap() - } - - pub async fn get_factory_pair( - &self, - input_asset: &Asset, - output_asset: &Asset, - ) -> Option
{ - let contract = self.factory_contract(); - - let result = contract.query( - "getPair", - ( - input_asset.as_address().unwrap(), - output_asset.as_address().unwrap(), - ), - None, - Options::default(), - None, - ); - - match result.await { - Ok(address) => Some(address), - _ => None, - } - } - - // TODO: it can be generic enough to use get_exchange_by_liquidity? - // may just use the same algorithm - pub async fn build_route_for(&self, input_asset: &Asset, output_asset: &Asset) -> Vec { - //TODO: use path_asset from input and output asset - // input -> path_asset -> path_asset from output -> output - //TODO: check liquidity of directly path - let mut v = vec![]; - //let network = self.get_network(); - // let wrapped_asset = network.get_wrapped_asset(); - let input_path_asset = input_asset.get_path_asset(); - let output_path_asset = output_asset.get_path_asset(); - let same_input_output_path_asset = - input_path_asset.address() == output_path_asset.address(); - let input_asset_is_same_of_some_asset_path = input_asset.address() - == input_path_asset.address() - || input_asset.address() == output_path_asset.address(); - let output_asset_is_same_of_some_asset_path = output_asset.address() - == input_path_asset.address() - || output_asset.address() == output_path_asset.address(); - // let has_direct_route = match self.get_factory_pair(input_asset, output_asset).await { - // Some(a) => (a.to_string().as_str() != ZERO_ADDRESS), - // _ => false, - // }; - - v.push(input_asset.as_address().unwrap()); - if !input_asset_is_same_of_some_asset_path && !output_asset_is_same_of_some_asset_path { - if same_input_output_path_asset { - v.push(input_path_asset.as_address().unwrap()); - } else { - v.push(input_path_asset.as_address().unwrap()); - v.push(output_path_asset.as_address().unwrap()); - } - } - // if !has_direct_route && !wrapped_is_output && !wrapped_is_input { - // v.push(wrapped_asset.as_address().unwrap()); - // } - v.push(output_asset.as_address().unwrap()); - - v - } - - //TODO: return error with value vec![zero] - pub async fn get_amounts_out( - &self, - // decimals: u8, - amount: U256, - assets_path: Vec, - ) -> Vec { - let zero = U256::from(0_i32); - - //TODO: check if the amount is sufficient - if amount == zero { - return vec![zero]; - } - - let contract = self.router_contract(); - let result = contract.query( - "getAmountsOut", - (amount, assets_path), - None, - Options::default(), - None, - ); - let result_amounts_out: Vec = match result.await { - Ok(a) => a, - Err(e) => { - tracing::error!( - "get_amounts_out(): error return zeroed value, result err: {:?},", - e - ); - vec![zero] - } - }; - result_amounts_out - } - - // TODO: take it to a shared module about blockchain - fn get_valid_timestamp(&self, future_millis: u128) -> u128 { - let start = SystemTime::now(); - let since_epoch = start.duration_since(UNIX_EPOCH).unwrap(); - since_epoch.as_millis().checked_add(future_millis).unwrap() - } - - pub fn get_network<'a>(&self) -> &'a Network { - Config::global() - .networks - .get(self.network_id.as_str()) - .unwrap() - } - - pub fn get_web3_client_http(&self) -> Web3 { - self.get_network().get_web3_client_rpc() - } - - pub async fn estimate_swap_cost( - &self, - from_wallet: &Wallet, - input_asset: &Asset, - output_asset: &Asset, - ) -> Result { - let asset_path = self - .build_route_for(input_asset, output_asset) - .await - .into_iter() - .collect::>(); - let asset_path_token = Token::Array( - asset_path - .clone() - .into_iter() - .map(Token::Address) - .collect::>(), - ); - - let output_asset_decimals = output_asset.decimals().await?; - let amount_in = input_asset.balance_of(from_wallet.address()).await?; - - let amount_out: U256 = self - .get_amounts_out(amount_in, asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - // Sum the slippage of the both assets the input and output. - let slippage = input_asset.slippage() + output_asset.slippage(); - - let slippage_amount = - math::get_slippage_amount(amount_out, slippage, output_asset_decimals); - let amount_min_out_slippage = amount_out - slippage_amount; - - match swap_tokens_for_tokens::estimate_gas( - self, - from_wallet, - amount_in, - amount_min_out_slippage, - asset_path_token, - ) - .await - { - Ok(gas) => Ok(gas), - Err(e) => { - tracing::error!( - "swap_cost() estimate_gas(): error: {}, input_asset: {:?}, amount_in: {:?}, amount_out: {:?} amount_min_out_slippage: {:?}", - e, - input_asset, - amount_in, - amount_out, - amount_min_out_slippage - ); - Err(anyhow::anyhow!(e)) - } - } - } - - pub async fn swap_tokens_for_tokens( - &self, - from_wallet: &Wallet, - amount_in: U256, - amount_min_out: U256, - input_asset: Asset, - output_asset: Asset, - slippage_opt: Option, - ) { - let asset_path = Token::Array( - self.build_route_for(&input_asset, &output_asset) - .await - .into_iter() - .map(Token::Address) - .collect::>(), - ); - - let asset_path_out = self.build_route_for(&output_asset, &input_asset).await; - let asset_path_in = self.build_route_for(&input_asset, &output_asset).await; - - let input_asset_decimals = input_asset.decimals().await.unwrap(); - let output_asset_decimals = output_asset.decimals().await.unwrap(); - - let slippage = match slippage_opt { - Some(s) => s, - None => { - input_asset.slippage_u256(output_asset_decimals) - + output_asset.slippage_u256(output_asset_decimals) - } - }; - - // TODO: move it to a func an test it - // check what input asset max tx amount limit is lower to use - // - // anonq 10000 = 1USD - // anonqv2 1000 = 1USD - // (anonq/anonqv2)*10000 = 10000 - // (anonqv2/anonqv2)*1000 = 1000 // use it - // - // anonq 10000 = 1USD - // anonqv2 1000 = 20USD - // (anonq/anonqv2)*10000 = 500 // use it - // (anonqv2/anonqv2)*1000 = 1000 - // - // amount_min_out = 0,05 - // amount_min_out*1000 = 50 - let i_max_tx_amount = input_asset.max_tx_amount().await; - let o_max_tx_amount = output_asset.max_tx_amount().await; - tracing::debug!("cmd::swap() i_max_tx_amount: {:?}", i_max_tx_amount); - tracing::debug!("cmd::swap() o_max_tx_amount: {:?}", o_max_tx_amount); - let limit_max_input = match (i_max_tx_amount, o_max_tx_amount) { - (Some(il), Some(ol)) => { - // anonq = 10_000 = 10000anonq - // safemoon = 10_000_000 = 249410anonq - // 10000*11000 = 111_000 - // 10_000*11000 = (10000*11000)*6,17 = 678_000 - - // 10000000*6,17 = 61.7MM - // 10000*1 = 10000 - let limit_amount_out: U256 = self - .get_amounts_out(ol, asset_path_out.clone()) - .await - .last() - .unwrap() - .into(); - - tracing::debug!( - "cmd::swap(): limit_amount_out: {:?}, limit_amount_out: {:?}", - limit_amount_out, - utils::blockchain::display_amount_to_float( - limit_amount_out, - input_asset_decimals - ) - ); - - if il > limit_amount_out { - Some(limit_amount_out) - } else { - Some(il) - } - } - (None, Some(ol)) => { - let limit_amount_in: U256 = self - .get_amounts_out(ol, asset_path_out.clone()) - .await - .last() - .unwrap() - .into(); - tracing::debug!("cmd::swap() limit_amount_in: {:?}", limit_amount_in); - Some(limit_amount_in) - } - (Some(il), None) => Some(il), - (None, None) => None, - }; - - tracing::debug!("cmd::swap() limit_max_output: {:?}", limit_max_input); - - match limit_max_input { - Some(limit) if amount_in > limit => { - let mut total = amount_in; - - let amount_in_bd = - BigDecimal::from_unsigned_u256(&amount_in, input_asset_decimals.into()); - let limit_bd = BigDecimal::from_unsigned_u256(&limit, input_asset_decimals.into()); - - let number_hops = amount_in_bd.div(limit_bd).to_f64().unwrap().ceil() as u64; - - for _ in 0..number_hops { - let ai: U256; - let ao: U256; - - if total > limit { - //TODO: calc amount_min_out - total -= limit; - tracing::debug!( - "cmd::swap() inside total > limit: total: {:?}, limit: {:?}", - total, - limit - ); - - ai = limit; - ao = self - .get_amounts_out(limit, asset_path_in.clone()) - .await - .last() - .unwrap() - .into(); - - tracing::debug!("cmd::swap() inside total > limit: ao: {:?}", ao); - } else { - ai = total; - ao = self - .get_amounts_out(total, asset_path_in.clone()) - .await - .last() - .unwrap() - .into(); - - tracing::debug!("cmd::swap() inside total > limit: ao: {:?}", ao); - } - - let slippage_amount = - (ao * slippage) / U256::exp10(output_asset_decimals.into()); - - let amount_min_out_slippage = ao - slippage_amount; - tracing::debug!("slippage_amount {:?}", slippage_amount); - - swap_tokens_for_tokens::swap( - self, - from_wallet, - ai, - amount_min_out_slippage, - asset_path.clone(), - ) - .await; - } - } - _ => { - swap_tokens_for_tokens::swap( - self, - from_wallet, - amount_in, - amount_min_out, - asset_path, - ) - .await; - } - } - } -} - -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct Exchanges(HashMap); -impl Exchanges { - pub fn hashmap(&self) -> &HashMap { - &self.0 - } - pub fn get(&self, key: &str) -> Option<&Exchange> { - self.0.get(key) - } -} diff --git a/src/config/exchange/swap_eth_for_tokens.rs b/src/config/exchange/swap_eth_for_tokens.rs deleted file mode 100644 index 82be9f6..0000000 --- a/src/config/exchange/swap_eth_for_tokens.rs +++ /dev/null @@ -1,79 +0,0 @@ -use crate::utils; - -use web3::{ - ethabi::Token, - types::{Bytes, TransactionParameters, U256}, -}; - -use crate::config::wallet::Wallet; - -use super::Exchange; - -pub async fn swap( - exchange: &Exchange, - from_wallet: &Wallet, - amount_in: U256, - amount_min_out: U256, - asset_path: Token, -) { - let client = exchange.get_web3_client_http(); - let gas_price = client.eth().gas_price().await.unwrap(); - let valid_timestamp = exchange.get_valid_timestamp(30000000); - let estimate_gas = exchange - .router_contract() - .estimate_gas( - "swapExactETHForTokensSupportingFeeOnTransferTokens", - // "swapExactTokensForTokens", - ( - amount_min_out, - asset_path.clone(), - from_wallet.address(), - U256::from_dec_str(&valid_timestamp.to_string()).unwrap(), - ), - from_wallet.address(), - web3::contract::Options { - value: Some(amount_in), - gas_price: Some(gas_price), - // gas: Some(500_000.into()), - // gas: Some(gas_price), - ..Default::default() - }, - ) - .await - .unwrap(); - - let func_data = exchange - .router_contract() - .abi() - .function("swapExactETHForTokensSupportingFeeOnTransferTokens") - // .function("swapExactTokensForTokens") - .unwrap() - .encode_input(&[ - Token::Uint(amount_min_out), - asset_path, - Token::Address(from_wallet.address()), - Token::Uint(U256::from_dec_str(&valid_timestamp.to_string()).unwrap()), - ]) - .unwrap(); - - let nonce = from_wallet.nonce(client.clone()).await.unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - let estimate_with_margin = - (estimate_gas * (U256::from(10000_i32) + U256::from(1000_i32))) / U256::from(10000_i32); - let transaction_obj = TransactionParameters { - nonce: Some(nonce), - to: Some(exchange.as_router_address().unwrap()), - value: amount_in, - gas_price: Some(gas_price), - gas: estimate_with_margin, - data: Bytes(func_data), - ..Default::default() - }; - - utils::blockchain::sign_send_and_wait_txn(client.clone(), transaction_obj, from_wallet) - .await - .unwrap(); -} diff --git a/src/config/exchange/swap_tokens_for_tokens.rs b/src/config/exchange/swap_tokens_for_tokens.rs deleted file mode 100644 index a594b03..0000000 --- a/src/config/exchange/swap_tokens_for_tokens.rs +++ /dev/null @@ -1,131 +0,0 @@ -use crate::utils; - -use web3::{ - contract::Error, - ethabi::Token, - types::{Bytes, TransactionParameters, U256}, -}; - -use crate::config::wallet::Wallet; - -use super::Exchange; - -pub async fn estimate_gas( - exchange: &Exchange, - from_wallet: &Wallet, - amount_in: U256, - amount_min_out: U256, - asset_path: Token, -) -> Result { - let client = exchange.get_web3_client_http(); - let gas_price = client.eth().gas_price().await.unwrap(); - let valid_timestamp = exchange.get_valid_timestamp(30000000); - exchange - .router_contract() - .estimate_gas( - "swapExactTokensForTokensSupportingFeeOnTransferTokens", - // "swapExactTokensForTokens", - ( - amount_in, - amount_min_out, - asset_path.clone(), - from_wallet.address(), - U256::from_dec_str(&valid_timestamp.to_string()).unwrap(), - ), - from_wallet.address(), - web3::contract::Options { - value: Some(U256::from(0_i32)), - gas_price: Some(gas_price), - // gas: Some(500_000.into()), - // gas: Some(gas_price), - ..Default::default() - }, - ) - .await -} - -pub async fn swap( - exchange: &Exchange, - from_wallet: &Wallet, - amount_in: U256, - amount_min_out: U256, - asset_path: Token, -) { - let client = exchange.get_web3_client_http(); - let gas_price = client.eth().gas_price().await.unwrap(); - let valid_timestamp = exchange.get_valid_timestamp(30000000); - let estimate_gas = match exchange - .router_contract() - .estimate_gas( - "swapExactTokensForTokensSupportingFeeOnTransferTokens", - // "swapExactTokensForTokens", - ( - amount_in, - amount_min_out, - asset_path.clone(), - from_wallet.address(), - U256::from_dec_str(&valid_timestamp.to_string()).unwrap(), - ), - from_wallet.address(), - web3::contract::Options { - value: Some(U256::from(0_i32)), - gas_price: Some(gas_price), - // gas: Some(500_000.into()), - // gas: Some(gas_price), - ..Default::default() - }, - ) - .await - { - Ok(e) => e, - Err(err) => { - // TODO: return error - tracing::error!("swap(): estimate_gas(): err: {}, asset_path: {:?}, amount_in: {:?}, amount_min_out: {:?}", err, asset_path, amount_in, amount_min_out); - panic!() - } - }; - - tracing::debug!("swap_tokens_for_tokens estimate_gas: {}", estimate_gas); - - let func_data = exchange - .router_contract() - .abi() - .function("swapExactTokensForTokensSupportingFeeOnTransferTokens") - // .function("swapExactTokensForTokens") - .unwrap() - .encode_input(&[ - Token::Uint(amount_in), - Token::Uint(amount_min_out), - asset_path, - Token::Address(from_wallet.address()), - Token::Uint(U256::from_dec_str(&valid_timestamp.to_string()).unwrap()), - ]) - .unwrap(); - tracing::debug!("swap_tokens_for_tokens(): func_data: {:?}", func_data); - - let nonce = from_wallet.nonce(client.clone()).await.unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - tracing::debug!("swap_tokens_for_tokens(): nonce: {:?}", nonce); - - let estimate_with_margin = - (estimate_gas * (U256::from(10000_i32) + U256::from(1000_i32))) / U256::from(10000_i32); - let transaction_obj = TransactionParameters { - nonce: Some(nonce), - to: Some(exchange.as_router_address().unwrap()), - value: U256::from(0_i32), - gas_price: Some(gas_price), - gas: estimate_with_margin, - data: Bytes(func_data), - ..Default::default() - }; - tracing::debug!( - "swap_tokens_for_tokens(): transaction_obj: {:?}", - transaction_obj - ); - - utils::blockchain::sign_send_and_wait_txn(client.clone(), transaction_obj, from_wallet) - .await - .unwrap(); -} diff --git a/src/config/mod.rs b/src/config/mod.rs deleted file mode 100644 index 0e5cabc..0000000 --- a/src/config/mod.rs +++ /dev/null @@ -1,65 +0,0 @@ -mod decrypt_wallet; -pub mod exchange; -pub mod network; -pub mod wallet; -pub mod withdraw_wallet; - -use once_cell::sync::OnceCell; -use serde::{Deserialize, Serialize}; - -use crate::{ - asset::config::AssetsConfig, notification::config::Notifications, - rebalancer::config::RebalancersConfig, -}; -use exchange::Exchanges; -use network::Networks; -use wallet::Wallets; -use withdraw_wallet::WithdrawWallets; - -static GLOBAL_CONFIG: OnceCell = OnceCell::new(); - -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct Server { - pub api_url: String, - pub api_token: String, -} - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct Config { - pub server: Option, - pub wallets: Wallets, - pub withdraw_wallets: Option, - pub networks: Networks, - pub exchanges: Exchanges, - pub assets: AssetsConfig, - pub rebalancers: Option, - pub notifications: Option, -} - -impl Config { - pub fn global() -> &'static Config { - GLOBAL_CONFIG.get().expect("CONFIG not loaded") - } - - pub fn from_file(f: &str) -> Result { - let reader = std::fs::File::open(f) - .map_err(|e| anyhow::anyhow!("failed to open a file, err: {:?}", e))?; - - let mut config: Config = serde_yaml::from_reader(reader).map_err(|e| { - anyhow::anyhow!("failed to deserialize the file to a Config, err: {:?}", e) - })?; - - if config.wallets.any_encrypted() { - config = decrypt_wallet::decrypt_wallets_from_config(config); - } - - // ask user password for each wallet - // decrypt private key - // overwrite in memory config with the private key decrypted - GLOBAL_CONFIG.set(config.clone()).unwrap(); - //TODO: before log, need filter some fields - //tracing::debug!("from_file(): config: {:?}", config); - - Ok(config) - } -} diff --git a/src/config/network.rs b/src/config/network.rs deleted file mode 100644 index cbd90ee..0000000 --- a/src/config/network.rs +++ /dev/null @@ -1,153 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use web3::{ - transports::{Http, WebSocket}, - types::U256, - Web3, -}; - -use super::{exchange::Exchange, wallet::Wallet, Config}; -use crate::{asset::Asset, utils::scalar::BigDecimal}; - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct Network { - name: String, - symbol: String, - decimals: Option, - chain_id: u32, - rpc_url: String, - node_url_http: Option, - blockexplorer_url: Option, - min_balance_coin: f64, - wrapped_asset: Option, -} - -impl Network { - pub fn rpc_url(&self) -> &str { - self.rpc_url.as_str() - } - - pub fn name(&self) -> &str { - self.name.as_str() - } - - pub fn symbol(&self) -> &str { - self.symbol.as_str() - } - - pub fn node_url(&self) -> Option { - self.node_url_http.clone() - } - - // TODO: try get this value from some request in the blockchain - pub fn coin_decimals(&self) -> u8 { - match self.decimals { - Some(n) => n, - _ => 18_u8, - } - } - - pub fn get_wrapped_asset(&self) -> Result { - match &self.wrapped_asset { - Some(wrapped_asset) => Config::global() - .assets - .find_by_name_and_network(wrapped_asset.as_str(), self.name.as_str()), - None => Err(anyhow::anyhow!("wrapped_asset not found")), - } - } - - //TODO: validate min_balance_coin in the build of the type - pub fn get_min_balance_coin(&self, decimals: u8) -> U256 { - BigDecimal::try_from(self.min_balance_coin) - .unwrap() - .with_scale(decimals.into()) - .to_unsigned_u256() - } - - pub fn get_web3_client_rpc(&self) -> Web3 { - self.get_web3_client_http(self.rpc_url()).unwrap() - } - - pub fn get_web3_client_http(&self, url: &str) -> Result, anyhow::Error> { - let http = Http::new(url).map_err(|e| anyhow::anyhow!(e))?; - Ok(Web3::new(http)) - } - - pub async fn get_web3_client_ws(&self) -> Result, anyhow::Error> { - match self.node_url() { - Some(n) => Ok(Web3::new(WebSocket::new(n.as_str()).await.unwrap())), - None => Err(anyhow::anyhow!("missing network.node_url configuration")), - } - } - - pub fn get_exchanges(&self) -> Vec<&Exchange> { - Config::global() - .exchanges - .hashmap() - .values() - .filter(|e| e.network_id() == self.name) - .collect() - } - - pub async fn balance_coin(&self, wallet: &Wallet) -> Result { - self - .get_web3_client_rpc() - .eth() - .balance(wallet.address(), None) - .await - .map_err(|e| anyhow::anyhow!("error fetch balance from network: {:?}", e)) - } - - pub async fn get_exchange_by_liquidity( - &self, - input_asset: &Asset, - output_asset: &Asset, - amount_in: U256, - ) -> Option<&Exchange> { - match self.get_exchanges().split_first() { - Some((h, t)) if t.is_empty() => Some(*h), - Some((h, t)) => { - let mut current_amount_out = { - let path = h.build_route_for(input_asset, output_asset).await; - *h.get_amounts_out(amount_in, path).await.last().unwrap() - }; - - futures::future::join_all(t.iter().map(|e| async move { - let current_amount = { - let path = e.build_route_for(input_asset, output_asset).await; - *e.get_amounts_out(amount_in, path).await.last().unwrap() - }; - (Some(*e), current_amount) - })) - .await - .into_iter() - .fold( - Some(*h), - |current_exchange, (next_exchange, next_amount)| { - if next_amount > current_amount_out { - current_amount_out = next_amount; - next_exchange - } else { - current_exchange - } - }, - ) - } - _ => { - tracing::debug!("Network::get_exchange_by_liquidity(): not exchange found, input_asset: {:?}, output_asset: {:?}", input_asset, output_asset); - None - } - } - } -} - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct Networks(HashMap); -impl Networks { - pub fn get(&self, key: &str) -> Option<&Network> { - self.0.get(key) - } - pub fn hashmap(&self) -> &HashMap { - &self.0 - } -} diff --git a/src/config/wallet.rs b/src/config/wallet.rs deleted file mode 100644 index b9ae7f8..0000000 --- a/src/config/wallet.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crate::utils::{password::SafePassword, signing}; - -use secp256k1::{PublicKey, Secp256k1, SecretKey}; -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, str::FromStr}; -use web3::{ - transports::Http, - types::{Address, U256}, -}; -use zeroize::Zeroizing; - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct Wallet { - #[serde(deserialize_with = "deserialize_safe_password")] - pub(crate) private_key: SafePassword, - pub(crate) env_password: Option, - pub(crate) encrypted: Option, -} - -// TODO: take it to password mod -fn deserialize_safe_password<'de, D>(deserializer: D) -> Result -where - D: serde::Deserializer<'de>, -{ - let password: String = Deserialize::deserialize(deserializer)?; - Ok(SafePassword::from(password)) -} - -impl Wallet { - pub fn private_key(&self) -> Zeroizing { - let bytes = self.private_key.reveal().to_vec(); - Zeroizing::new(String::from_utf8(bytes).unwrap()) - } - - pub fn secret(&self) -> SecretKey { - // TODO: add a wrap to zeroize the secret key too - SecretKey::from_str(self.private_key().as_str()).unwrap() - } - - pub fn public(&self) -> PublicKey { - let secp = Secp256k1::new(); - let s = self.secret(); - PublicKey::from_secret_key(&secp, &s) - } - - pub fn address(&self) -> Address { - signing::public_key_address(&self.public()) - } - - pub async fn nonce(&self, client: web3::Web3) -> Result { - client - .eth() - .transaction_count(self.address(), None) - .await - .map_err(|e| anyhow::anyhow!("failed to fetch nonce, got: {:?}", e)) - } - - pub async fn coin_balance(&self, client: web3::Web3) -> U256 { - match client.eth().balance(self.address(), None).await { - Ok(n) => n, - Err(_) => U256::default(), - } - } -} - -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct Wallets(pub(crate) HashMap); -impl Wallets { - pub fn get(&self, key: &str) -> Option<&Wallet> { - self.0.get(key) - } - - pub fn hashmap(&self) -> &HashMap { - &self.0 - } - - pub fn any_encrypted(&self) -> bool { - self.0 - .values() - .map(|wallet| wallet.encrypted.unwrap_or(false)) - .any(|b| b) - } -} diff --git a/src/config/withdraw_wallet.rs b/src/config/withdraw_wallet.rs deleted file mode 100644 index 6f10372..0000000 --- a/src/config/withdraw_wallet.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::collections::HashMap; - -use serde::{Deserialize, Serialize}; -use std::str::FromStr; -use web3::types::Address; - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct WithdrawWallet { - address: String, -} - -impl WithdrawWallet { - pub fn address(&self) -> String { - self.address.clone() - } - - pub fn as_address(&self) -> Address { - Address::from_str(&self.address()).unwrap() - } -} - -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct WithdrawWallets(HashMap); - -impl WithdrawWallets { - pub fn get(&self, key: &str) -> &WithdrawWallet { - self.0.get(key).unwrap() - } -} diff --git a/src/encrypt/cmd.rs b/src/encrypt/cmd.rs deleted file mode 100644 index 9d3f5d2..0000000 --- a/src/encrypt/cmd.rs +++ /dev/null @@ -1,10 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("encrypt").about("Encrypt data with a password") -} - -#[tracing::instrument(name = "encrypt call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/encrypt/mod.rs b/src/encrypt/mod.rs deleted file mode 100644 index 9924530..0000000 --- a/src/encrypt/mod.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::utils::{self, password::encrypt_private_key_to_base64}; -use clap::ArgMatches; - -pub mod cmd; - -#[tracing::instrument(name = "run encrypt")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let password = utils::password::prompt_password("Type a password: ").unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - let private_key = utils::password::prompt_password("Paste the wallet private key: ") - .unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - let base64 = encrypt_private_key_to_base64(password, private_key); - - println!("Encrypted key as base64: {}", base64); - - Ok(()) -} diff --git a/src/notification/config.rs b/src/notification/config.rs deleted file mode 100644 index 3694a31..0000000 --- a/src/notification/config.rs +++ /dev/null @@ -1,28 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use super::{telegram::TelegramNotifier, Notifier}; - -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct Notifications(Vec); - -impl Notifications { - pub fn all_notifiers(&self) -> Vec { - self.clone().0.iter().map(|n| n.notifier()).collect() - } -} - -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[serde(rename_all = "snake_case", tag = "type")] -pub enum NotificationKind { - Telegram { token: String, chat_id: i64 }, -} - -impl NotificationKind { - pub fn notifier(&self) -> impl Notifier { - match self { - NotificationKind::Telegram { token, chat_id } => { - TelegramNotifier::new(token.to_string(), *chat_id) - } - } - } -} diff --git a/src/notification/debug.rs b/src/notification/debug.rs deleted file mode 100644 index 431f1f9..0000000 --- a/src/notification/debug.rs +++ /dev/null @@ -1,11 +0,0 @@ -use super::Notifier; - -#[derive(Default)] -pub struct DebugNotifier {} - -impl Notifier for DebugNotifier { - fn send(&self, message: String) -> Result<(), anyhow::Error> { - tracing::info!("{}", message); - Ok(()) - } -} diff --git a/src/notification/mod.rs b/src/notification/mod.rs deleted file mode 100644 index 0991dbf..0000000 --- a/src/notification/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub mod config; -pub mod debug; -pub mod telegram; - -pub trait Notifier { - fn send(&self, message: String) -> Result<(), anyhow::Error>; -} - -pub fn notify(notifier: T, message: String) -> Result<(), anyhow::Error> { - notifier.send(message) -} - -pub fn notify_all(notifiers: &[T], message: String) -> Result<(), anyhow::Error> { - notifiers - .iter() - .try_for_each(|notifier| -> Result<(), anyhow::Error> { - notifier.send(message.clone())?; - Ok(()) - }) -} diff --git a/src/notification/telegram.rs b/src/notification/telegram.rs deleted file mode 100644 index 4b77c75..0000000 --- a/src/notification/telegram.rs +++ /dev/null @@ -1,34 +0,0 @@ -use futures::executor; -use teloxide::{ - requests::{Request, Requester}, - types::ChatId, - Bot, -}; - -use super::Notifier; - -#[derive(Debug)] -pub struct TelegramNotifier { - bot: Bot, - chat_id: ChatId, -} - -impl TelegramNotifier { - pub fn new(token: String, chat_id: i64) -> Self { - Self { - bot: Bot::new(token), - chat_id: ChatId(chat_id), - } - } -} - -impl Notifier for TelegramNotifier { - fn send(&self, message: String) -> Result<(), anyhow::Error> { - let message = executor::block_on(self.bot.send_message(self.chat_id, message).send()) - .map_err(|e| anyhow::anyhow!("telegram send message error: {:?}", e))?; - - tracing::info!("telegram message sent: {:?}", message); - - Ok(()) - } -} diff --git a/src/quote/cmd.rs b/src/quote/cmd.rs deleted file mode 100644 index b43f402..0000000 --- a/src/quote/cmd.rs +++ /dev/null @@ -1,26 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("quote") - .about("Get a quote for tokens to tokens") - .arg(clap::arg!(-n --"network" "Network to use, ex (bsc, polygon)").required(true)) - .arg(clap::arg!(-e --"exchange" "Exchange to use router").required(false)) - .arg( - clap::arg!(-a --"amount" "Amount of TokenA to swap to TokenB") - .required(false) - .value_parser(clap::value_parser!(f64)), - ) - .arg(clap::arg!(-i --"token_input" "Asset of input token").required(false)) - .arg(clap::arg!(-o --"token_output" "Asset of output token").required(false)) - .arg( - clap::arg!(-s --"slippage" "Slippage (default 0.5)") - .required(false) - .default_value("0.5") - .value_parser(clap::value_parser!(f64)), - ) -} - -#[tracing::instrument(name = "quote call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/quote/mod.rs b/src/quote/mod.rs deleted file mode 100644 index e890b5b..0000000 --- a/src/quote/mod.rs +++ /dev/null @@ -1,69 +0,0 @@ -use crate::{ - cmd::helpers, - utils::{self, math}, -}; -use clap::ArgMatches; -use prettytable::{row, Table}; -use web3::types::U256; - -pub mod cmd; - -#[tracing::instrument(name = "run quote")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let network = helpers::get_network(args)?; - - let input_asset = helpers::get_token_input_in_network_from_args(args, network.name())?; - let output_asset = helpers::get_token_output_in_network_from_args(args, network.name())?; - - let input_asset_decimals = input_asset.decimals().await?; - let output_asset_decimals = output_asset.decimals().await?; - let amount_in = helpers::get_amount(args, input_asset_decimals)?; - - let exchange = match helpers::get_exchange(args) { - Ok(e) => e, - Err(_) => { - tracing::warn!("exchange not found in args, try to use the best liquidity exchange"); - - network - .get_exchange_by_liquidity(&input_asset, &output_asset, amount_in) - .await - .unwrap() - } - }; - - let slippage = helpers::get_slippage(args)?; - - let asset_path = exchange.build_route_for(&input_asset, &output_asset).await; - - let amount_min_out: U256 = exchange - .get_amounts_out(amount_in, asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - let slippage_amount = - math::get_slippage_amount(amount_min_out, slippage, output_asset_decimals); - let amount_out_slippage: U256 = amount_min_out - slippage_amount; - - let mut table = Table::new(); - table.add_row(row![ - "Exchange", - "From Asset", - "From Asset Amount", - "To Asset", - "To Asset Amount", - "To Asset Amount with Slippage", - ]); - table.add_row(row![ - exchange.name(), - input_asset.name(), - utils::blockchain::display_amount_to_float(amount_in, input_asset_decimals), - output_asset.name(), - utils::blockchain::display_amount_to_float(amount_min_out, output_asset_decimals), - utils::blockchain::display_amount_to_float(amount_out_slippage, output_asset_decimals), - ]); - table.printstd(); - - Ok(()) -} diff --git a/src/rebalancer/cmd.rs b/src/rebalancer/cmd.rs deleted file mode 100644 index a91bdfa..0000000 --- a/src/rebalancer/cmd.rs +++ /dev/null @@ -1,398 +0,0 @@ -use chrono::prelude::*; -use std::ops::{Div, Mul}; - -use crate::{ - cmd, - rebalancer::{ - self, config::Strategy, generate_asset_rebalances, get_total_quoted_balance, AssetBalances, move_asset_with_slippage - }, - track, - utils::{blockchain::display_amount_to_float, scalar::BigDecimal}, -}; -use clap::{ArgMatches, Command}; -use prettytable::{row, Table}; -use web3::types::U256; - -pub const REBALANCER_COMMAND: &str = "rebalancer"; -pub const REBALANCER_RUN_COMMAND: &str = "run"; -pub const REBALANCER_INFO_COMMAND: &str = "info"; -pub const REBALANCER_EXIT_COMMAND: &str = "exit"; - -pub fn generate_info_cmd() -> Command { - Command::new(REBALANCER_INFO_COMMAND) - .about("Infos about rebalancer") - .arg( - clap::arg!(-n --"name" "Rebalancer name from config file") - .required(true), - ) - .arg( - clap::arg!(-s --"run-every" "Run continuously at every number of seconds") - .value_parser(clap::value_parser!(u32)), - ) - .arg( - clap::arg!(-t --"track" "Run track command after the info") - .required(false) - .default_value("false"), - ) -} - -pub fn generate_run_cmd() -> Command { - Command::new(REBALANCER_RUN_COMMAND) - .about("Run rebalancer") - .arg( - clap::arg!(-n --"name" "Rebalancer name from config file") - .required(true), - ) -} - -pub fn generate_exit_cmd() -> Command { - Command::new(REBALANCER_EXIT_COMMAND) - .about("Exit all positions of the portfolio to parking asset") - .arg( - clap::arg!(-n --"name" "Rebalancer name from config file") - .required(true), - ) -} - -pub fn generate() -> Command { - Command::new(REBALANCER_COMMAND) - .about("Fires a rebalancer") - .subcommand(generate_run_cmd()) - .subcommand(generate_info_cmd()) - .subcommand(generate_exit_cmd()) -} - -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - match args.subcommand() { - Some((REBALANCER_RUN_COMMAND, sub_args)) => cmd_run(sub_args).await, - Some((REBALANCER_INFO_COMMAND, sub_args)) => cmd_info(sub_args).await, - Some((REBALANCER_EXIT_COMMAND, sub_args)) => cmd_exit(sub_args).await, - _ => Err(anyhow::anyhow!("no sub cmd found")), - } -} - -async fn cmd_exit(args: &ArgMatches) -> Result<(), anyhow::Error> { - let mut config = cmd::helpers::get_rebalancer(args); - tracing::debug!( - "rebalancer::cmd::call_sub_commands(): rebalancer_config: {:?}", - config - ); - - // TODO: a guarantee to try to move - config.parking_asset_min_move = -0.1; - - let assets = config.get_assets()?; - let assets_balances = rebalancer::get_assets_balances(&config, assets).await?; - - { - let rebalancer_config = &config; - let assets_balances = &assets_balances; - let parking_asset = rebalancer_config.get_parking_asset(); - - //TODO: do it to until all the balance are in the parking asset - for ab in assets_balances.iter() { - if ab.asset.name() == rebalancer_config.parking_asset_id() { - continue; - } - - let exchange = ab.asset - .get_network() - .get_exchange_by_liquidity(&ab.asset, &parking_asset, ab.balance) - .await.unwrap_or_else(||{ - tracing::error!( - "move_assets_to_parking(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - ab.asset, - parking_asset - ); - panic!() - }); - - let parking_asset_path = exchange.build_route_for(&ab.asset, &parking_asset).await; - - let parking_amount_out: U256 = exchange - .get_amounts_out(ab.balance, parking_asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - let min_move = - rebalancer_config.parking_asset_min_move_u256(parking_asset.decimals().await.unwrap()); - if min_move >= parking_amount_out { - tracing::warn!( - "min_move not satisfied: min_move {}, parking_amount_out {}", - min_move, - parking_amount_out - ); - //TODO: return this error? - continue; - } - - move_asset_with_slippage( - rebalancer_config, - &ab.asset, - &parking_asset, - ab.balance, - parking_amount_out, - ) - .await; - } - }; - Ok(()) -} - -async fn cmd_run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let config = cmd::helpers::get_rebalancer(args); - tracing::debug!( - "rebalancer::cmd::call_sub_commands(): rebalancer_config: {:?}", - config - ); - - rebalancer::validate(&config).await?; - - match config.strategy() { - Strategy::FullParking => { - tracing::debug!("rebalancer::cmd::call_sub_commands() Strategy::FullParking"); - rebalancer::run_full_parking(&config).await - } - Strategy::DiffParking => { - tracing::debug!("rebalancer::cmd::call_sub_commands() Strategy::DiffParking"); - tracing::info!("running run_diff_parking by Strategy::DiffParking"); - rebalancer::run_diff_parking(&config).await - } - } -} - -async fn wrapped_cmd_info(args: &ArgMatches) -> Result<(), anyhow::Error> { - let config = cmd::helpers::get_rebalancer(args); - let asset_quoted = &config.get_quoted_asset(); - let asset_quoted_decimals = asset_quoted.decimals().await.unwrap(); - let mut portifolio_balance = U256::default(); - - let mut table = Table::new(); - let mut wallet_table = Table::new(); - - let utc_time = Local::now(); - - wallet_table.add_row(row![ - "wallet", - format!("{:?}", config.get_wallet().address()), - "running_at", - utc_time.to_rfc2822() - ]); - - table.add_row(row![ - "Asset", - "Percent", - "Price", - "Balance", - "Quoted In", - "Balance in quoted", - "Amount to trade", - "Quoted amount to trade", - "Current Percent" - ]); - - let asset_rebalances = generate_asset_rebalances(&config) - .await - .unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - let assets_balances: Vec = asset_rebalances - .clone() - .iter() - .map(|ar| ar.asset_balances.clone()) - .collect(); - - let total_quoted = get_total_quoted_balance(assets_balances.as_slice()); - - asset_rebalances.clone().iter().for_each(|ar| { - let balance_of = ar.asset_balances.balance; - let asset = ar.asset_balances.asset.clone(); - let decimals = ar.asset_balances.asset_decimals; - let amount_in_quoted = ar.asset_balances.quoted_balance; - let asset_quoted_decimals = ar.asset_balances.quoted_asset_decimals; - - let amount_in_quoted_bd = BigDecimal::from_unsigned_u256( - &ar.asset_balances.quoted_balance, - asset_quoted_decimals.into(), - ); - - let balance_of_bd = BigDecimal::from_unsigned_u256(&balance_of, decimals.into()); - portifolio_balance += amount_in_quoted; - - let price = { - if balance_of_bd == BigDecimal::zero() { - BigDecimal::from_unsigned_u256( - &ar.asset_balances.quoted_unit_price, - asset_quoted_decimals.into(), - ) - .to_f64() - .unwrap() - } else { - amount_in_quoted_bd - .clone() - .div(balance_of_bd.clone()) - .with_scale(asset_quoted_decimals.into()) - .to_f64() - .unwrap() - } - }; - - table.add_row(row![ - asset.name(), - ar.asset_balances.percent(), - price, - balance_of_bd.to_f64().unwrap(), - config.quoted_in(), - amount_in_quoted_bd.to_f64().unwrap(), - ar.amount_f64_with_sign(ar.asset_amount_to_trade, decimals), - ar.amount_f64_with_sign(ar.quoted_amount_to_trade, asset_quoted_decimals), - (amount_in_quoted_bd.to_f64().unwrap() - / BigDecimal::from_unsigned_u256(&total_quoted, asset_quoted_decimals.into()) - .to_f64() - .unwrap()) - * 100.0 - ]); - }); - - let mut info_table = Table::new(); - info_table.add_row(row!["Min threshold", config.threshold_percent, "%"]); - - let asset_balances: Vec = asset_rebalances - .clone() - .into_iter() - .map(|ar| ar.asset_balances) - .collect(); - - info_table.add_row(row![ - "Current threshold", - config - .current_percent_diff(&asset_balances) - .mul(BigDecimal::try_from(100.0_f64).unwrap()) - .with_scale(4), - "%" - ]); - - info_table.add_row(row![ - "Current amount to trade", - config.current_total_amount_to_trade(&asset_rebalances), - asset_quoted.name() - ]); - - let network = config.get_network(); - let client = network.get_web3_client_rpc(); - let rebalancer_wallet = config.get_wallet(); - let coin_balance = rebalancer_wallet.coin_balance(client.clone()).await; - let mut balances_table = Table::new(); - - balances_table.add_row(row![ - "Portifolio balance", - display_amount_to_float(portifolio_balance, asset_quoted_decimals), - asset_quoted.name() - ]); - - balances_table.add_row(row![ - "Coin balance", - display_amount_to_float(coin_balance, network.coin_decimals()), - network.symbol() - ]); - - let parking_asset = config.get_parking_asset(); - let from_wallet = config.get_wallet(); - - // TODO: handle with the possibility to have just one asset. - // By example, using a rebalancer exit command and just have a parking asset. - // May a network default wrapped asset. - let input_asset = match asset_rebalances - .clone() - .iter() - .filter(|ar| { - (ar.asset_balances.asset.name() != parking_asset.name()) - && ar.asset_balances.max_tx_amount.is_none() - && ar.asset_balances.balance > U256::from(0) - }) - .last() - { - Some(ar) => Some(ar.asset_balances.asset.clone()), - None => { - tracing::warn!("No input asset to calculate swap cost"); - None - } - }; - - if let Some(input_asset) = input_asset { - let amount_in = input_asset.balance_of(from_wallet.address()).await?; - let parking_asset_exchange = input_asset - .get_network() - .get_exchange_by_liquidity(&input_asset, &parking_asset, amount_in) - .await.unwrap_or_else(||{ - tracing::error!( - "cmd_info(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - input_asset.clone(), - parking_asset - ); - panic!() - }); - - let gas_price = client.clone().eth().gas_price().await.unwrap(); - let swap_cost = parking_asset_exchange - .estimate_swap_cost(from_wallet, &input_asset, &parking_asset) - .await?; - - let total_ops = U256::from(asset_rebalances.len()); - - balances_table.add_row(row![ - "Total Swap cost", - display_amount_to_float((swap_cost * gas_price) * total_ops, network.coin_decimals()), - network.symbol() - ]); - balances_table.add_row(row![ - "Swap cost", - display_amount_to_float(swap_cost * gas_price, network.coin_decimals()), - network.symbol() - ]); - balances_table.add_row(row![ - "Gas price", - display_amount_to_float(gas_price, network.coin_decimals()), - network.symbol() - ]); - } - - wallet_table.printstd(); - table.printstd(); - info_table.printstd(); - balances_table.printstd(); - - match cmd::helpers::get_track(args) { - true => track::wrapped_run(args).await, - false => Ok(()), - } -} - -async fn cmd_info(args: &ArgMatches) -> Result<(), anyhow::Error> { - tracing::debug!("cmd_info()"); - - let run_every = cmd::helpers::get_run_every(args); - - match run_every { - Some(every_seconds) => loop { - match wrapped_cmd_info(args).await { - Ok(_) => {} - Err(e) => tracing::error!( - "ignored by run_every config, error running wrapped_cmd_info(): {:?}", - e - ), - } - - let duration = std::time::Duration::from_secs((*every_seconds).into()); - std::thread::sleep(duration); - - // breaking line in the terminal to the possible next call - print!("\n\n"); - }, - None => wrapped_cmd_info(args).await, - } -} diff --git a/src/rebalancer/config.rs b/src/rebalancer/config.rs deleted file mode 100644 index 7e7c8b4..0000000 --- a/src/rebalancer/config.rs +++ /dev/null @@ -1,254 +0,0 @@ -use crate::asset::Asset; -use crate::config::network::Network; -use crate::utils::math; -use crate::utils::scalar::BigDecimal; -use crate::{config::wallet::Wallet, config::Config}; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::ops::{Add, Div, Sub}; -use web3::types::U256; - -use super::{AssetBalances, AssetRebalancer, Kind}; - -#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum Strategy { - FullParking, - DiffParking, -} - -#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] -struct AssetConfig { - // asset_id: String, - percent: f64, -} - -// TODO: validate portfolio max percent -// TODO: validate that all routes (n-to-n) to the assets exist -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct Portfolio(HashMap); - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct RebalancerConfig { - pub(crate) name: String, - pub(crate) wallet_id: String, - pub(crate) network_id: String, - pub(crate) portfolio: Portfolio, - pub(crate) strategy: Strategy, - pub(crate) threshold_percent: f64, - pub(crate) quoted_in: String, - pub(crate) parking_asset_id: String, - // TODO: refactor the move_assets_to_parking function to be reusable and have another function - // to exit command. - pub(crate) parking_asset_min_move: f64, -} - -impl RebalancerConfig { - pub fn parking_asset_min_move_u256(&self, decimals: u8) -> U256 { - math::f64_to_u256(self.parking_asset_min_move, decimals) - } - - pub fn network_id(&self) -> &str { - self.network_id.as_str() - } - - pub fn name(&self) -> String { - self.name.clone() - } - - pub fn strategy(&self) -> Strategy { - self.strategy.clone() - } - - pub fn total_percentage(&self) -> f64 { - self.portfolio - .0 - .values() - .map(|asset_config| asset_config.percent) - .sum() - } - - pub fn is_valid_portfolio_total_percentage(&self) -> bool { - const REQUIRED: f64 = 100.0; - self.total_percentage().eq(&REQUIRED) - } - - pub fn get_asset_config_percent(&self, name: &str) -> f64 { - match self.portfolio.0.get(name) { - Some(a) => a.percent, - None => { - tracing::error!("RebalancerConfig::get_asset_config_percent(): asset_name {} doesnt exist in portfolio", name); - panic!() - } - } - } - - pub fn get_assets(&self) -> Result, anyhow::Error> { - self.portfolio - .0 - .keys() - .map(|name| { - Config::global() - .assets - .find_by_name_and_network(name.as_str(), self.network_id.as_str()) - }) - .collect() - } - - pub fn quoted_in(&self) -> &str { - self.quoted_in.as_str() - } - - pub fn parking_asset_id(&self) -> &str { - self.parking_asset_id.as_str() - } - - pub fn get_quoted_asset(&self) -> Asset { - Config::global() - .assets - .find_by_name_and_network(self.quoted_in(), self.network_id.as_str()) - .unwrap() - } - - pub fn get_parking_asset(&self) -> Asset { - Config::global() - .assets - .find_by_name_and_network(self.parking_asset_id.as_str(), self.network_id.as_str()) - .unwrap() - } - - // TODO: refactor RebalancerConfig to carry the wallet and avoid panic here - pub fn get_wallet<'a>(&self) -> &'a Wallet { - Config::global().wallets.get(&self.wallet_id).unwrap() - } - - pub fn get_network(&self) -> &Network { - match Config::global().networks.get(self.network_id()) { - Some(n) => n, - _ => panic!("missing network for rebalancer"), - } - } - - pub fn threshold_percent(&self) -> f64 { - self.threshold_percent - } - - /* - Returns true if the percentual difference between current portfolio tokes amount - and the expected. - - A algorithm to get percent diff between current and expected portfolio tokens: - ```numi.app - each_percent=0,25 = 0,25 - - now_btc_quoted=250 = 250 - now_eth_quoted=250 = 250 - now_anonq_quoted=250 = 250 - now_bnb_quoted=500 = 500 - now_total=now_btc_quoted+now_eth_quoted+now_anonq_quoted+now_bnb_quoted = 1.250 - - percent_now_btc = now_btc_quoted/now_total = 0,2 - percent_now_eth = now_eth_quoted/now_total = 0,2 - percent_now_anonq = now_anonq_quoted/now_total = 0,2 - percent_now_bnb = now_bnb_quoted/now_total = 0,4 - - percent_diff=abs(percent_now_btc-each_percent)+abs(percent_now_eth-each_percent)+abs(percent_now_anonq-each_percent)+abs(percent_now_bnb-each_percent) = 0,3 - - threshold = 0,02 = 0,02 - - threshold-percent_diff = -0,28 - ``` - */ - - pub fn u256_abs_diff(&self, qap: U256, pn: U256) -> U256 { - if qap.ge(&pn) { - qap - pn - } else { - pn - qap - } - } - - pub fn current_total_amount_to_trade( - &self, - assets_rebalances: &[AssetRebalancer], - ) -> BigDecimal { - assets_rebalances - .iter() - .fold(BigDecimal::from(0_i32), |acc, x| { - let quoted_amount_to_trade = BigDecimal::from_unsigned_u256( - &x.quoted_amount_to_trade, - x.asset_balances.quoted_asset_decimals().into(), - ); - - match x.kind { - Kind::FromParking => acc.add(quoted_amount_to_trade), - _ => acc.add(BigDecimal::zero()), - } - }) - } - - pub fn current_percent_diff(&self, assets_balances: &[AssetBalances]) -> BigDecimal { - let total_quoted = assets_balances - .iter() - .fold(BigDecimal::from(0_i32), |acc, x| { - acc + BigDecimal::from_unsigned_u256( - &x.quoted_balance(), - x.quoted_asset_decimals().into(), - ) - }); - - let sum_percent_diff = - assets_balances - .iter() - .fold(BigDecimal::from(0_i32), |acc, asset_balances| { - let quoted_balance_bd = BigDecimal::from_unsigned_u256( - &asset_balances.quoted_balance(), - asset_balances.quoted_asset_decimals().into(), - ); - - if quoted_balance_bd <= BigDecimal::from(0_i32) { - return acc; - } - - let quoted_asset_percent_bd = math::percent_to_bigdecimal( - asset_balances.percent(), - asset_balances.quoted_asset_decimals(), - ); - - let p_now_bd = quoted_balance_bd.div(total_quoted.clone()); - let p_diff_bd = quoted_asset_percent_bd.sub(p_now_bd).abs(); - - acc + p_diff_bd - }); - - //max_percent.sub(sum_percent_diff).with_scale(4) - let total_sides = BigDecimal::from(2_i32); - let round_scale = 4_u8; - sum_percent_diff - .div(total_sides) - .with_scale(round_scale.into()) - } - - // TODO: add tests and refactor this function - pub fn reach_min_threshold(&self, assets_balances: &[AssetBalances]) -> bool { - let percent_decimal = 4_u8; - let threshold_percent = - math::percent_to_bigdecimal(self.threshold_percent(), percent_decimal); - let current_percent_diff = self - .current_percent_diff(assets_balances) - .with_scale(percent_decimal.into()); - - current_percent_diff.ge(&threshold_percent) - } -} - -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub struct RebalancersConfig(HashMap); -impl RebalancersConfig { - pub fn hashmap(&self) -> &HashMap { - &self.0 - } - pub fn get(&self, key: &str) -> &RebalancerConfig { - self.0.get(key).unwrap() - } -} diff --git a/src/rebalancer/mod.rs b/src/rebalancer/mod.rs deleted file mode 100644 index 638ad3b..0000000 --- a/src/rebalancer/mod.rs +++ /dev/null @@ -1,657 +0,0 @@ -pub mod cmd; -pub mod config; - -use std::ops::{Mul, Sub}; - -use crate::{ - asset::Asset, - rebalancer::config::RebalancerConfig, - utils::{math::percent_to_u256, scalar::BigDecimal}, -}; - -use serde::{Deserialize, Serialize}; -use web3::types::U256; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct AssetBalances { - //TODO add a equal operation for Asset - pub(crate) asset: Asset, - pub(crate) asset_decimals: u8, - pub(crate) percent: f64, - pub(crate) balance: U256, - pub(crate) quoted_asset_decimals: u8, - pub(crate) quoted_balance: U256, - pub(crate) quoted_unit_price: U256, - pub(crate) max_tx_amount: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub enum Kind { - ToParking, - FromParking, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct AssetRebalancer { - pub(crate) kind: Kind, - pub(crate) rebalancer_config: RebalancerConfig, - pub(crate) asset_balances: AssetBalances, - pub(crate) quoted_amount_to_trade: U256, - pub(crate) asset_amount_to_trade: U256, - pub(crate) parking_amount_to_trade: U256, -} - -impl AssetRebalancer { - //TODO: refact this initialization to split initialization, build and validations - pub async fn new( - kind: Kind, - rebalancer_config: RebalancerConfig, - asset_balances: AssetBalances, - quoted_amount_to_trade: U256, - ) -> Option { - let quoted_asset = rebalancer_config.get_quoted_asset(); - let parking_asset = rebalancer_config.get_parking_asset(); - - let asset_exchange = asset_balances.asset - .get_network() - .get_exchange_by_liquidity(&asset_balances.asset, "ed_asset, asset_balances.balance) - .await.unwrap_or_else(||{ - tracing::error!( - "AssetRebalancer::new(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - &asset_balances.asset, - quoted_asset - ); - panic!() - }); - - let parking_exchange = quoted_asset - .get_network() - .get_exchange_by_liquidity("ed_asset, &parking_asset, quoted_amount_to_trade) - .await.unwrap_or_else(||{ - tracing::error!( - "AssetRebalancer::new(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - quoted_asset, - parking_asset - ); - panic!() - }); - - let quoted_asset_path = asset_exchange - .build_route_for("ed_asset, &asset_balances.asset) - .await; - - let quoted_parking_asset_path = parking_exchange - .build_route_for("ed_asset, &rebalancer_config.get_parking_asset()) - .await; - - let parking_amount_to_trade: U256 = parking_exchange - .get_amounts_out(quoted_amount_to_trade, quoted_parking_asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - let asset_amount_to_trade: U256 = asset_exchange - .get_amounts_out(quoted_amount_to_trade, quoted_asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - Some(Self { - kind, - rebalancer_config, - asset_balances, - quoted_amount_to_trade, - asset_amount_to_trade, - parking_amount_to_trade, - }) - } - - pub fn amount_f64_with_sign(&self, amount: U256, decimals: u8) -> f64 { - let amount_bd = BigDecimal::from_unsigned_u256(&amount, decimals.into()); - let amount_f64 = amount_bd.with_scale(decimals.into()).to_f64().unwrap(); - match self.kind { - Kind::ToParking => amount_f64.mul(-1.0), - Kind::FromParking => amount_f64.mul(1.0), - } - } -} - -impl AssetBalances { - pub async fn new( - rebalancer_config: &RebalancerConfig, - asset: Asset, - ) -> Result { - let quoted_asset = rebalancer_config.get_quoted_asset(); - let asset_decimals = asset.decimals().await?; - let unit_amount = U256::from(1_u32) * U256::exp10(asset_decimals.into()); - - let exchange = asset - .get_network() - .get_exchange_by_liquidity(&asset, "ed_asset, unit_amount) - .await - .unwrap(); - - let quoted_asset_path = exchange.build_route_for(&asset, "ed_asset).await; - let quoted_unit_price: U256 = exchange - .get_amounts_out(unit_amount, quoted_asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - //TODO: refactor it to dont need to unwraps from the query functions - Ok(Self { - asset: asset.clone(), - quoted_unit_price, - asset_decimals, - percent: rebalancer_config.get_asset_config_percent(asset.name()), - balance: asset - .balance_of(rebalancer_config.get_wallet().address()) - .await?, - quoted_asset_decimals: quoted_asset.decimals().await?, - quoted_balance: asset - .balance_of_quoted_in(rebalancer_config.get_wallet(), "ed_asset) - .await - .unwrap(), - max_tx_amount: asset.max_tx_amount().await, - }) - } - - pub fn get_amount_by_percent(&self, total_balance: U256, decimals: u8) -> U256 { - get_amount_to_trade(total_balance, U256::zero(), self.percent, decimals).to_unsigned_u256() - } - - pub fn quoted_balance(&self) -> U256 { - self.quoted_balance - } - pub fn quoted_asset_decimals(&self) -> u8 { - self.quoted_asset_decimals - } - pub fn percent(&self) -> f64 { - self.percent - } - pub fn quoted_asset_percent_u256(&self) -> U256 { - percent_to_u256(self.percent, self.quoted_asset_decimals) - } -} - -pub fn get_amount_to_trade( - total_balance: U256, - balance: U256, - percent: f64, - decimals: u8, -) -> BigDecimal { - let total_balance_bd = BigDecimal::from_unsigned_u256(&total_balance, decimals.into()); - let balance_bd = BigDecimal::from_unsigned_u256(&balance, decimals.into()); - let percent_bd = BigDecimal::try_from(percent / 100.0).unwrap(); - - total_balance_bd - .mul(percent_bd) - .sub(balance_bd) - .with_scale(decimals.into()) -} - -pub async fn get_assets_balances( - rebalancer_config: &RebalancerConfig, - assets: Vec, -) -> Result, anyhow::Error> { - futures::future::join_all( - assets - .into_iter() - .map(|asset| { - AssetBalances::new(rebalancer_config, asset) - }) - ).await.into_iter().collect() -} - -pub async fn add_parking_asset( - rebalancer_config: &RebalancerConfig, - ab: Vec, -) -> Result, anyhow::Error> { - let parking_asset = rebalancer_config.get_parking_asset(); - - if ab.iter().any(|a| a.asset.name() == parking_asset.name()) { - return Ok(ab); - } - - let pab = AssetBalances::new(rebalancer_config, parking_asset).await?; - - Ok(ab.into_iter().chain(vec![pab].into_iter()).collect()) -} - -pub fn get_total_quoted_balance(assets_balances: &[AssetBalances]) -> U256 { - let total = assets_balances - .iter() - .fold(U256::from(0_i32), |acc, x| acc + x.quoted_balance); - - total -} - -pub async fn move_asset_with_slippage( - rebalancer_config: &RebalancerConfig, - asset_in: &Asset, - asset_out: &Asset, - mut amount_in: U256, - mut amount_out: U256, -) { - let from_wallet = rebalancer_config.get_wallet(); - let balance = asset_in.balance_of(from_wallet.address()).await.unwrap(); - let exchange = rebalancer_config.get_network().get_exchange_by_liquidity(asset_in, asset_out, amount_in).await - .unwrap_or_else(|| { - tracing::error!( - "move_asset_with_slippage(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - asset_in, - asset_out - ); - panic!() - }); - - //TODO: handle with it before in another place - if balance < amount_in { - amount_in = balance; - let p = exchange.build_route_for(asset_in, asset_out).await; - amount_out = exchange - .get_amounts_out(amount_in, p) - .await - .last() - .unwrap() - .into(); - } - - let asset_out_decimals = asset_out.decimals().await.unwrap(); - - let slippage = - asset_in.slippage_u256(asset_out_decimals) + asset_out.slippage_u256(asset_out_decimals); - - let slippage_amount = (amount_out * slippage) / U256::exp10(asset_out_decimals.into()); - - let asset_out_amount_slip = amount_out - slippage_amount; - tracing::debug!("asset_out_amount_slip: {:?}", asset_out_amount_slip); - - exchange - .swap_tokens_for_tokens( - from_wallet, - amount_in, - asset_out_amount_slip, - asset_in.clone(), - asset_out.clone(), - Some(slippage), - ) - .await; -} - -pub async fn move_assets_to_parking( - rebalancer_config: &RebalancerConfig, - assets_balances: &[AssetBalances], -) { - let parking_asset = rebalancer_config.get_parking_asset(); - - //TODO: do it to until all the balance are in the parking asset - for ab in assets_balances.iter() { - if ab.asset.name() == rebalancer_config.parking_asset_id() { - continue; - } - - let exchange = ab.asset - .get_network() - .get_exchange_by_liquidity(&ab.asset, &parking_asset, ab.balance) - .await.unwrap_or_else(||{ - tracing::error!( - "move_assets_to_parking(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - ab.asset, - parking_asset - ); - panic!() - }); - - let parking_asset_path = exchange.build_route_for(&ab.asset, &parking_asset).await; - - let parking_amount_out: U256 = exchange - .get_amounts_out(ab.balance, parking_asset_path.clone()) - .await - .last() - .unwrap() - .into(); - - let min_move = - rebalancer_config.parking_asset_min_move_u256(parking_asset.decimals().await.unwrap()); - if min_move >= parking_amount_out { - tracing::warn!( - "min_move not satisfied: min_move {}, parking_amount_out {}", - min_move, - parking_amount_out - ); - //TODO: return this error? - continue; - } - - move_asset_with_slippage( - rebalancer_config, - &ab.asset, - &parking_asset, - ab.balance, - parking_amount_out, - ) - .await; - } -} - -pub async fn move_parking_to_assets( - rebalancer_config: &RebalancerConfig, - assets_balances: &[AssetBalances], -) { - let from_wallet = rebalancer_config.get_wallet(); - let parking_asset = rebalancer_config.get_parking_asset(); - let parking_asset_decimals = parking_asset.decimals().await.unwrap(); - - //TODO: check if doenst exist balance in other assets - let total_parking_balance = parking_asset - .balance_of(from_wallet.address()) - .await - .unwrap(); - - //TODO: do it to until all the parking balance are in the respective assets - for ab in assets_balances.iter() { - if ab.asset.name() == rebalancer_config.parking_asset_id() { - continue; - } - - let parking_slippage = parking_asset.slippage_u256(ab.asset_decimals); - let parking_amount = - ab.get_amount_by_percent(total_parking_balance, parking_asset_decimals); - tracing::debug!("desired_parking_to_move: {}", parking_amount); - - let exchange = ab.asset - .get_network() - .get_exchange_by_liquidity(&parking_asset, &ab.asset, parking_amount) - .await.unwrap_or_else(||{ - tracing::error!( - "move_parking_to_assets(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - parking_asset, - ab.asset - ); - panic!() - }); - - let asset_route = exchange.build_route_for(&parking_asset, &ab.asset).await; - - let asset_amount_out: U256 = exchange - .get_amounts_out(parking_amount, asset_route.clone()) - .await - .last() - .unwrap() - .into(); - tracing::debug!("asset_amount_out: {:?}", asset_amount_out); - - let ab_slippage = ab.asset.slippage_u256(ab.asset_decimals); - let slippage = ab_slippage + parking_slippage; - tracing::debug!("slippage: {:?}", slippage); - - let slippage_amount = (asset_amount_out * slippage) / U256::exp10(ab.asset_decimals.into()); - tracing::debug!("slippage_amount: {:?}", slippage_amount); - - let asset_amount_out_slip = asset_amount_out - slippage_amount; - tracing::debug!("asset_amount_out_slip: {:?}", asset_amount_out_slip); - - let min_move = rebalancer_config.parking_asset_min_move_u256(parking_asset_decimals); - if min_move >= parking_amount { - tracing::error!( - "min_move not sattisfied: min_move {}, parking_amounts_out {}", - min_move, - parking_amount - ); - continue; - } - - exchange - .swap_tokens_for_tokens( - from_wallet, - parking_amount, - asset_amount_out_slip, - parking_asset.clone(), - ab.asset.clone(), - Some(slippage), - ) - .await; - } -} - -//TODO: break validation and threshold -pub async fn validate(config: &RebalancerConfig) -> Result<(), anyhow::Error> { - if !config.is_valid_portfolio_total_percentage() { - tracing::error!( - "rebalancer: {}, sum of portfolio percent should be 100, current is: {}", - config.name(), - config.total_percentage() - ); - panic!() - } - - let assets = config.get_assets()?; - let assets_balances = get_assets_balances(config, assets).await?; - - if !config.reach_min_threshold(&assets_balances) { - return Err(anyhow::anyhow!(format!( - "rebalancer: {}, the minimum threshold configured was not reached", - config.name() - ))); - } - - Ok(()) -} - -pub async fn run_full_parking(config: &RebalancerConfig) -> Result<(), anyhow::Error> { - //TODO: doc it - // the general idea of a full parking - // calc how much we need for each asset - // calc the diff of expect with current balance per asset - // swap the balances of all assets to the parking_asset - // calc quoted_balance of the parking_asset - // buy from parking_asset the percent of each asset - // check if the portfolio is balanced - let from_wallet = config.get_wallet(); - let parking_asset = config.get_parking_asset(); - let assets = config.get_assets()?; - let assets_balances = get_assets_balances(config, assets).await?; - - move_assets_to_parking(config, &assets_balances).await; - - let total_parking_balance = parking_asset.balance_of(from_wallet.address()).await?; - tracing::debug!( - "run_rebalancer_full_parking(): after move assets_to_parking: total_parking_balance: {}", - total_parking_balance - ); - - move_parking_to_assets(config, &assets_balances).await; - - let total_parking_balance = parking_asset.balance_of(from_wallet.address()).await?; - tracing::debug!( - "run_rebalancer_full_parking(): after move parking_to_assets: total_parking_balance: {}", - total_parking_balance - ); - - Ok(()) -} - -pub async fn run_diff_parking_per_kind( - config: &RebalancerConfig, - kind: Kind, - ar: Vec, -) { - let parking_asset = config.get_parking_asset(); - - //TODO: when from_parking, check if weve balance from parking, if not, use all balance - for ar in ar - .iter() - .filter(|ar| ar.kind == kind && ar.asset_balances.asset.name() != parking_asset.name()) - { - let (asset_in, asset_out, amount_in, amount_out) = match kind { - Kind::ToParking => ( - &ar.asset_balances.asset, - &parking_asset, - ar.asset_amount_to_trade, - ar.parking_amount_to_trade, - ), - Kind::FromParking => ( - &parking_asset, - &ar.asset_balances.asset, - ar.parking_amount_to_trade, - ar.asset_amount_to_trade, - ), - }; - - let min_move = config - .parking_asset_min_move_u256(config.get_parking_asset().decimals().await.unwrap()); - - if min_move >= ar.parking_amount_to_trade { - tracing::debug!("run_diff_parking_per_kind(): min_move >= ar.parking_amount_to_trade, min_move: {}, ar.parking_amount_to_trade: {}", min_move, ar.parking_amount_to_trade); - continue; - } - - tracing::debug!("diff_parking: parking_to_asset: asset_in.name: {}, asset_out.name: {}, amount_in: {:?}, amount_out: {:?}", asset_in.name(), asset_out.name(), amount_in, amount_out); - - tracing::info!("run_diff_parking_per_kind: move_asset_with_slippage: asset_in ({}), asset_out ({}), amount_in ({:?}), amount_out ({:?})", asset_in.name(), asset_out.name(), amount_in, amount_out); - move_asset_with_slippage(config, asset_in, asset_out, amount_in, amount_out).await - } -} - -pub async fn generate_asset_rebalances( - config: &RebalancerConfig, -) -> Result, anyhow::Error> { - let assets = config.get_assets()?; - - //TODO: add thresould per position - - let mut total = BigDecimal::zero(); - - let assets_balances = get_assets_balances(config, assets.clone()).await?; - let assets_balances_with_parking = add_parking_asset(config, assets_balances).await?; - - let total_quoted_balance = assets_balances_with_parking - .iter() - .fold(U256::from(0_i32), |acc, x| acc + x.quoted_balance()); - - tracing::debug!( - "diff_parking: total_quoted_balance: {}", - total_quoted_balance - ); - - let mut asset_rebalances = vec![]; - - // TODO: break this for in functions to return rp_to_parking rp_from_parking - for ab in assets_balances_with_parking.clone() { - tracing::debug!( - "generate_asset_rebalances(): loop assets_balances_with_parking; ab: {:?}", - ab - ); - let amount_to_trade = get_amount_to_trade( - total_quoted_balance, - ab.quoted_balance, - ab.percent, - ab.quoted_asset_decimals, - ); - - total = total + amount_to_trade.clone(); - - // if amount_to_trade is negative, move to parking - let kind = if amount_to_trade <= BigDecimal::zero() { - Kind::ToParking - } else { - Kind::FromParking - }; - - match AssetRebalancer::new( - kind, - config.clone(), - ab.clone(), - amount_to_trade.abs().to_unsigned_u256(), - ) - .await - { - Some(ar) => asset_rebalances.push(ar), - None => { - tracing::debug!("diff_parking: rebalancer_parking cant be created, continue."); - continue; - } - }; - - tracing::debug!("diff_parking: ab: {}, quoted_balance: {}, ab.percent(): {}, amount_to_trade: {}, total: {}", - ab.asset.name(), - ab.quoted_balance, - ab.percent, - amount_to_trade, - total, - ); - } - - Ok(asset_rebalances) -} - -pub async fn run_diff_parking(config: &RebalancerConfig) -> Result<(), anyhow::Error> { - let asset_rebalancers = generate_asset_rebalances(config).await?; - - run_diff_parking_per_kind(config, Kind::ToParking, asset_rebalancers.clone()).await; - run_diff_parking_per_kind(config, Kind::FromParking, asset_rebalancers.clone()).await; - - Ok(()) -} - -mod test { - #[test] - fn get_amount_to_trade_test() { - use crate::rebalancer::get_amount_to_trade; - use crate::utils::scalar::BigDecimal; - use web3::types::U256; - - struct TestCase { - total_balance: U256, - balance: U256, - percent: f64, - decimals: u8, - expected: BigDecimal, - } - - let test_cases = vec![ - TestCase { - total_balance: BigDecimal::from(20000_i32) - .with_scale(18) - .to_unsigned_u256(), - balance: BigDecimal::from(100_i32).with_scale(18).to_unsigned_u256(), - percent: 10.0, - decimals: 18_u8, - expected: BigDecimal::from(1900_i32), - }, - TestCase { - total_balance: BigDecimal::from(17333_i32) - .with_scale(18) - .to_unsigned_u256(), - balance: BigDecimal::from(97_i32).with_scale(18).to_unsigned_u256(), - percent: 2.5, - decimals: 18_u8, - expected: BigDecimal::try_from(336.325).unwrap(), - }, - TestCase { - total_balance: BigDecimal::from(20000_i32) - .with_scale(18) - .to_unsigned_u256(), - balance: BigDecimal::from(2000_i32).with_scale(18).to_unsigned_u256(), - percent: 2.0, - decimals: 18_u8, - expected: BigDecimal::from(-1600_i32), - }, - ]; - - for test_case in test_cases { - let amount_to_trade = get_amount_to_trade( - test_case.total_balance, - test_case.balance, - test_case.percent, - test_case.decimals, - ); - - assert_eq!(test_case.expected, amount_to_trade) - } - } -} diff --git a/src/swap/cmd.rs b/src/swap/cmd.rs deleted file mode 100644 index 78e5fe5..0000000 --- a/src/swap/cmd.rs +++ /dev/null @@ -1,27 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("swap") - .about("Swap Tokens for Tokens supporting fees on transfer") - .arg(clap::arg!(-n --"network" "Network to use, ex (bsc, polygon)").required(true)) - .arg(clap::arg!(-e --"exchange" "Exchange to use router. If not provided, try to use best liquidity exchange").required(false)) - .arg(clap::arg!(-w --"wallet" "Wallet id from config file").required(true)) - .arg( - clap::arg!(-a --"amount" "Amount of TokenA to swap to TokenB") - .required(false) - .value_parser(clap::value_parser!(f64)), - ) - .arg(clap::arg!(-i --"token_input" "Asset of input token").required(false)) - .arg(clap::arg!(-o --"token_output" "Asset of output token").required(false)) - .arg( - clap::arg!(-s --"slippage" "Slippage (default 0.5)") - .required(false) - .default_value("0.5") - .value_parser(clap::value_parser!(f64)), - ) -} - -#[tracing::instrument(name = "swap call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/swap/mod.rs b/src/swap/mod.rs deleted file mode 100644 index 0d3f5ce..0000000 --- a/src/swap/mod.rs +++ /dev/null @@ -1,86 +0,0 @@ -use crate::{ - cmd::helpers, - utils::{self, math}, -}; -use clap::ArgMatches; -use prettytable::{row, Table}; -use web3::types::U256; - -pub mod cmd; - -#[tracing::instrument(name = "run swap")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let network = helpers::get_network(args)?; - - let input_asset = helpers::get_token_input_in_network_from_args(args, network.name()).unwrap(); - tracing::debug!("input_token: {:?}", input_asset); - let output_asset = - helpers::get_token_output_in_network_from_args(args, network.name()).unwrap(); - tracing::debug!("output_token: {:?}", output_asset); - - let input_asset_decimals = input_asset.decimals().await.unwrap(); - let output_asset_decimals = output_asset.decimals().await.unwrap(); - - let amount_in = helpers::get_amount(args, input_asset_decimals)?; - - let exchange = match helpers::get_exchange(args) { - Ok(e) => e, - Err(_) => { - tracing::warn!("exchange not found in args, try to use the best liquidity exchange"); - - network - .get_exchange_by_liquidity(&input_asset, &output_asset, amount_in) - .await - .unwrap() - } - }; - - let from_wallet = helpers::get_wallet(args).unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - let slippage = helpers::get_slippage(args)?; - - let asset_path_in = exchange.build_route_for(&input_asset, &output_asset).await; - - let amount_min_out: U256 = exchange - .get_amounts_out(amount_in, asset_path_in.clone()) - .await - .last() - .unwrap() - .into(); - tracing::debug!("amount_mint_out: {:?}", amount_min_out); - - let slippage_amount = - math::get_slippage_amount(amount_min_out, slippage, output_asset_decimals); - let amount_out_slippage = amount_min_out - slippage_amount; - - exchange - .swap_tokens_for_tokens( - from_wallet, - amount_in, - amount_out_slippage, - input_asset.clone(), - output_asset.clone(), - Some(math::f64_to_u256(slippage, output_asset_decimals)), - ) - .await; - - let mut table = Table::new(); - table.add_row(row![ - "From Asset", - "From Asset Amount", - "To Asset", - "To Asset Amount", - ]); - table.add_row(row![ - input_asset.name(), - utils::blockchain::display_amount_to_float(amount_in, input_asset_decimals), - output_asset.name(), - utils::blockchain::display_amount_to_float(amount_out_slippage, output_asset_decimals), - ]); - table.printstd(); - - Ok(()) -} diff --git a/src/track/cmd.rs b/src/track/cmd.rs deleted file mode 100644 index aaa4f43..0000000 --- a/src/track/cmd.rs +++ /dev/null @@ -1,15 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("track") - .about("Track all information to server") - .arg( - clap::arg!(-s --"run-every" "Run continuously at every number of seconds") - .value_parser(clap::value_parser!(u32)), - ) -} - -#[tracing::instrument(name = "track call command", level = "debug")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/track/mod.rs b/src/track/mod.rs deleted file mode 100644 index 9bace26..0000000 --- a/src/track/mod.rs +++ /dev/null @@ -1,236 +0,0 @@ -use super::rebalancer::generate_asset_rebalances; -use crate::{ - asset::Asset, cmd::helpers, config::Config, utils::blockchain::display_amount_to_float, -}; -use clap::ArgMatches; -use serde::{Deserialize, Serialize}; -use web3::types::U256; - -pub mod cmd; - -const API_TOKEN_HEADER: &str = "X-Api-Token"; - -//TODO: change the name of the tables like this -#[derive(Deserialize, Serialize, Clone)] -struct TrackAsset { - asset: Asset, - price: f64, - balance: f64, - quoted_asset: Asset, - quoted_balance: f64, - amount_to_trade: f64, - quoted_amount_to_trade: f64, -} - -#[derive(Deserialize, Serialize, Clone)] -pub struct TrackPortfolioStateData { - portfolio_name: String, - track_assets: Vec, - quoted_portfolio_asset: Asset, - quoted_portfolio_balance: f64, - coin_balance: f64, - total_estimate_swap_cost: f64, - estimate_swap_cost: f64, - gas_price: f64, -} - -#[derive(Deserialize, Serialize, Clone)] -pub struct TrackPortfolioState { - rebalancer_label: String, - data: TrackPortfolioStateData, -} - -#[tracing::instrument(name = "wrapped run track", level = "debug")] -pub(crate) async fn wrapped_run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let config = Config::global(); - let (api_token, api_address) = match &config.server { - Some(s) => (s.api_token.clone(), s.api_url.clone()), - None => return Err(anyhow::anyhow!("track::cmd_run(): config.server missing")), - }; - - for (rebalancer_name, rebalancer_config) in match config.rebalancers.clone() { - Some(rebalancers) => rebalancers, - None => { - return Err(anyhow::anyhow!( - "track::cmd_run(): rebalancer is not configured" - )) - } - } - .hashmap() - .iter() - { - tracing::info!( - "track::cmd_run(): rebalancer_name: {:?}, rebalancer_config: {:?}", - rebalancer_name, - rebalancer_config - ); - // TODO: back it when finish the break of validate - // rebalancer::validate(rebalancer_config).await; - - let quoted_portfolio_asset = rebalancer_config.get_quoted_asset(); - let asset_quoted_decimals = quoted_portfolio_asset.decimals().await?; - - let asset_rebalancers = generate_asset_rebalances(rebalancer_config).await?; - - let track_assets = asset_rebalancers - .clone() - .iter() - .map(|ar| TrackAsset { - asset: ar.asset_balances.asset.clone(), - price: display_amount_to_float( - ar.asset_balances.quoted_unit_price, - asset_quoted_decimals, - ), - balance: display_amount_to_float( - ar.asset_balances.balance, - ar.asset_balances.asset_decimals, - ), - quoted_asset: ar.rebalancer_config.get_quoted_asset(), - quoted_balance: display_amount_to_float( - ar.asset_balances.quoted_balance, - asset_quoted_decimals, - ), - amount_to_trade: ar.amount_f64_with_sign( - ar.asset_amount_to_trade, - ar.asset_balances.asset_decimals, - ), - quoted_amount_to_trade: ar - .amount_f64_with_sign(ar.quoted_amount_to_trade, asset_quoted_decimals), - }) - .collect(); - - let quoted_portfolio_balance_u256 = - asset_rebalancers - .clone() - .iter() - .fold(U256::from(0_u32), |acc, ar| { - let amount_in_quoted = ar.asset_balances.quoted_balance; - acc + amount_in_quoted - }); - let quoted_portfolio_balance = - display_amount_to_float(quoted_portfolio_balance_u256, asset_quoted_decimals); - - let network = rebalancer_config.get_network(); - let client = network.get_web3_client_rpc(); - let rebalancer_wallet = rebalancer_config.get_wallet(); - let coin_balance_u256 = rebalancer_wallet.coin_balance(client.clone()).await; - let coin_balance = display_amount_to_float(coin_balance_u256, network.coin_decimals()); - - let parking_asset = rebalancer_config.get_parking_asset(); - let from_wallet = rebalancer_config.get_wallet(); - - // TODO: handle with the possibility to have just one asset. - // By example, using a rebalancer exit command and just have a parking asset. - // May a network default wrapped asset. - let input_asset = match asset_rebalancers - .clone() - .iter() - .filter(|ar| { - (ar.asset_balances.asset.name() != parking_asset.name()) - && ar.asset_balances.max_tx_amount.is_none() - && ar.asset_balances.balance > U256::from(0) - }) - .last() - { - Some(ar) => ar.asset_balances.asset.clone(), - None => return Err(anyhow::anyhow!("no input asset to calculate swap cost")), - }; - - let amount_in = input_asset.balance_of(from_wallet.address()).await?; - let parking_asset_exchange = input_asset - .get_network() - .get_exchange_by_liquidity(&input_asset, &parking_asset, amount_in) - .await - .unwrap_or_else(|| { - tracing::error!( - "cmd_info(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}", - input_asset.clone(), - parking_asset - ); - panic!() - }); - - let gas_price_u256 = client - .clone() - .eth() - .gas_price() - .await - .map_err(|e| anyhow::anyhow!("error on getch gas_price, got: {:?}", e))?; - let swap_cost = parking_asset_exchange - .estimate_swap_cost(from_wallet, &input_asset, &parking_asset) - .await?; - - let total_ops = U256::from(asset_rebalancers.len()); - - let total_estimate_swap_cost = display_amount_to_float( - (swap_cost * gas_price_u256) * total_ops, - network.coin_decimals(), - ); - let estimate_swap_cost = - display_amount_to_float(swap_cost * gas_price_u256, network.coin_decimals()); - let gas_price = display_amount_to_float(gas_price_u256, network.coin_decimals()); - - let track_portfolio_state = { - let data = TrackPortfolioStateData { - portfolio_name: rebalancer_name.to_string(), - track_assets, - quoted_portfolio_asset, - quoted_portfolio_balance, - coin_balance, - total_estimate_swap_cost, - estimate_swap_cost, - gas_price, - }; - TrackPortfolioState { - rebalancer_label: rebalancer_name.to_string(), - data, - } - }; - - let string_body = serde_json::to_string(&track_portfolio_state).unwrap(); - - match { - // TODO: should have a mod to handle with mfm-server (bindings) - let client = reqwest::Client::new(); - client - .post(&format!("{}/portfolio_state", api_address)) - .header("Content-Type", "application/json") - .header(API_TOKEN_HEADER, api_token.clone()) - .body(string_body) - .send() - .await - } { - Ok(response) => { - tracing::info!("track::cmd_run() http request response: {:?}", response); - } - Err(e) => { - return Err(anyhow::anyhow!( - "track::cmd_run() http request failed, got: {:?}", - e - )) - } - } - } - - Ok(()) -} - -#[tracing::instrument(name = "run track")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let run_every = helpers::get_run_every(args); - - match run_every { - Some(every_seconds) => loop { - match wrapped_run(args).await { - Ok(_) => {} - Err(e) => tracing::error!( - "ignored by run_every config, error running wrapped_run(): {:?}", - e - ), - } - let duration = std::time::Duration::from_secs((*every_seconds).into()); - std::thread::sleep(duration); - }, - None => wrapped_run(args).await, - } -} diff --git a/src/unwrap/cmd.rs b/src/unwrap/cmd.rs deleted file mode 100644 index 97b1761..0000000 --- a/src/unwrap/cmd.rs +++ /dev/null @@ -1,18 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("unwrap") - .about("Unwrap a wrapped coin to coin") - .arg(clap::arg!(-n --"network" "Network to unwrap token to coin").required(true)) - .arg(clap::arg!(-w --"wallet" "Wallet id from config file").required(true)) - .arg( - clap::arg!(-a --"amount" "Amount to unwrap token into coin") - .required(false) - .value_parser(clap::value_parser!(f64)), - ) -} - -#[tracing::instrument(name = "unwrap call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/unwrap/mod.rs b/src/unwrap/mod.rs deleted file mode 100644 index 659b6e9..0000000 --- a/src/unwrap/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::cmd::helpers; -use clap::ArgMatches; - -pub mod cmd; - -#[tracing::instrument(name = "run unwrap")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let wallet = helpers::get_wallet(args)?; - let network = helpers::get_network(args)?; - - let wrapped_asset = network.get_wrapped_asset()?; - let wrapped_asset_decimals = wrapped_asset.decimals().await?; - - let amount_in = helpers::get_amount(args, wrapped_asset_decimals)?; - - wrapped_asset.unwrap(wallet, amount_in).await -} diff --git a/src/utils/blockchain.rs b/src/utils/blockchain.rs deleted file mode 100644 index 892ae66..0000000 --- a/src/utils/blockchain.rs +++ /dev/null @@ -1,149 +0,0 @@ -use core::time; -use std::thread; - -use web3::{ - contract::{tokens::Tokenize, Contract, Options}, - ethabi::Token, - transports::Http, - types::{ - Address, Bytes, SignedTransaction, TransactionParameters, TransactionReceipt, H256, U256, - }, - Web3, -}; - -use crate::{asset::Asset, config::wallet::Wallet}; - -use super::scalar::BigDecimal; - -pub async fn estimate_gas

( - contract: &Contract, - from_wallet: &Wallet, - func_name: &str, - params: P, - options: Options, -) -> Result -where - P: Tokenize, -{ - // let gas_price = client.eth().gas_price().await.unwrap(); - let estimate_gas = contract - .estimate_gas(func_name, params, from_wallet.address(), options) - .await - .map_err(|e| anyhow::anyhow!("failed to execute estimate_gas, got: {:?}", e))?; - - Ok((estimate_gas * (U256::from(10000_i32) + U256::from(1000_i32))) / U256::from(10000_i32)) -} - -pub fn generate_func_data( - contract: &Contract, - func_name: &str, - input: &[Token], -) -> Result, anyhow::Error> { - contract - .abi() - .function(func_name) - .unwrap() - .encode_input(input) - .map_err(|e| { - anyhow::anyhow!( - "failed to generate with this input to this func, got: {:?}", - e - ) - }) -} - -pub fn build_transaction_params( - nonce: U256, - to: Address, - value: U256, - gas_price: U256, - estimate_gas: U256, - func_data: Bytes, -) -> TransactionParameters { - TransactionParameters { - nonce: Some(nonce), - to: Some(to), - value, - gas_price: Some(gas_price), - gas: estimate_gas, - data: func_data, - ..Default::default() - } -} - -pub async fn sign_transaction( - client: Web3, - transaction_obj: TransactionParameters, - from_wallet: &Wallet, -) -> SignedTransaction { - let secret = from_wallet.secret(); - client - .accounts() - .sign_transaction(transaction_obj, &secret) - .await - .unwrap() -} - -pub async fn send_raw_transaction( - client: Web3, - signed_transaction: SignedTransaction, -) -> Result { - client - .eth() - .send_raw_transaction(signed_transaction.raw_transaction) - .await - .map_err(|e| anyhow::anyhow!("failed to send raw transaction, got: {:?}", e)) -} - -pub async fn sign_send_and_wait_txn( - client: Web3, - transaction_obj: TransactionParameters, - from_wallet: &Wallet, -) -> Result<(), anyhow::Error> { - let signed_transaction = sign_transaction(client.clone(), transaction_obj, from_wallet).await; - let tx_address = send_raw_transaction(client.clone(), signed_transaction).await?; - - let receipt = wait_receipt(client.clone(), tx_address).await?; - tracing::debug!("receipt: {:?}", receipt); - - Ok(()) -} - -pub async fn wait_receipt( - client: web3::Web3, - tx_address: H256, -) -> Result { - loop { - match client.eth().transaction_receipt(tx_address).await { - Ok(Some(receipt)) => return Ok(receipt), - Ok(None) => { - thread::sleep(time::Duration::from_secs(5)); - continue; - } - Err(e) => return Err(anyhow::anyhow!(e)), - } - } -} - -pub fn display_amount_to_float(amount: U256, decimals: u8) -> f64 { - BigDecimal::from_unsigned_u256(&amount, decimals.into()) - .to_f64() - .unwrap() -} - -pub async fn amount_in_quoted(asset_in: &Asset, asset_quoted: &Asset, amount_in: U256) -> U256 { - let exchange = asset_in - .get_network() - .get_exchange_by_liquidity(asset_in,asset_quoted, amount_in) - .await. - unwrap_or_else(||{ - tracing::error!("move_parking_to_assets(): network.get_exchange_by_liquidity(): None, asset_in: {:?}, asset_out: {:?}",asset_in,asset_quoted); - panic!() - }); - - let path = exchange.build_route_for(asset_in, asset_quoted).await; - match exchange.get_amounts_out(amount_in, path).await.last() { - Some(p) => *p, - None => U256::default(), - } -} diff --git a/src/utils/hidden.rs b/src/utils/hidden.rs deleted file mode 100644 index 6e50657..0000000 --- a/src/utils/hidden.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2020. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -//! A wrapper to conceal secrets when output into logs or displayed. - -use std::{fmt, ops::DerefMut}; - -use serde::{Deserialize, Serialize}; - -/// A simple struct with a single inner value to wrap content of any type. -#[derive(Copy, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct Hidden { - inner: T, -} - -impl Hidden { - /// Returns ownership of the inner value discarding the wrapper. - pub fn into_inner(self) -> T { - self.inner - } -} - -impl From for Hidden { - fn from(inner: T) -> Self { - Hidden { inner } - } -} - -/// Defines a masked value for the type to output as debug information. Concealing the secrets within. -impl fmt::Debug for Hidden { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Hidden<{}>", std::any::type_name::()) - } -} - -/// Defines a masked value for the type to display. Concealing the secrets within. -impl fmt::Display for Hidden { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Hidden<{}>", std::any::type_name::()) - } -} - -/// Attempts to make the wrapper more transparent by having deref return a reference to the inner value. -impl std::ops::Deref for Hidden { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl DerefMut for Hidden { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner - } -} - -impl PartialEq for Hidden { - fn eq(&self, other: &Self) -> bool { - self.inner == other.inner - } -} - -impl Eq for Hidden {} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn into_applies_wrapper_deref_removes_it() { - let wrapped: Hidden = 42.into(); - assert_eq!(42, *wrapped) - } -} diff --git a/src/utils/math.rs b/src/utils/math.rs deleted file mode 100644 index 394c573..0000000 --- a/src/utils/math.rs +++ /dev/null @@ -1,116 +0,0 @@ -use std::ops::Mul; -use web3::types::U256; - -use super::scalar::BigDecimal; - -//TODO: add test to all functions - -pub fn to_percent(value: f64) -> f64 { - value / 100.0 -} - -pub fn f64_to_u256(value: f64, decimals: u8) -> U256 { - f64_to_bigdecimal(value, decimals).to_unsigned_u256() -} - -pub fn f64_to_bigdecimal(value: f64, decimals: u8) -> BigDecimal { - BigDecimal::try_from(value) - .unwrap() - .with_scale(decimals.into()) -} - -pub fn percent_to_bigdecimal(percent: f64, decimals: u8) -> BigDecimal { - f64_to_bigdecimal(to_percent(percent), decimals) -} - -pub fn percent_to_u256(percent: f64, decimals: u8) -> U256 { - f64_to_u256(to_percent(percent), decimals) -} - -pub fn get_slippage_amount(amount: U256, slippage: f64, decimals: u8) -> U256 { - let amount_bd = BigDecimal::from_unsigned_u256(&amount, decimals.into()); - let slippage_bd = percent_to_bigdecimal(slippage, decimals); - - amount_bd - .mul(slippage_bd) - .with_scale(decimals.into()) - .to_unsigned_u256() -} - -mod test { - #[test] - fn get_slippage_amount_test() { - use crate::utils::{math::get_slippage_amount, scalar::BigDecimal}; - use web3::types::U256; - - struct TestCase { - amount: U256, - slippage: f64, - decimals: u8, - expected: U256, - } - - let test_cases = vec![ - TestCase { - amount: BigDecimal::from(12).with_scale(18).to_unsigned_u256(), - slippage: 2.0, - decimals: 18, - expected: BigDecimal::try_from(12.0 * 0.02) - .unwrap() - .with_scale(18) - .to_unsigned_u256(), - }, - TestCase { - amount: BigDecimal::from(12).with_scale(6).to_unsigned_u256(), - slippage: 1.5, - decimals: 6, - expected: U256::from(180000_u32), - }, - TestCase { - amount: U256::from(153987924_u32), - slippage: 4.0, - decimals: 6, - expected: U256::from(6159516_u32), - }, - TestCase { - amount: BigDecimal::from(12).with_scale(18).to_unsigned_u256(), - slippage: 0.5, - decimals: 18, - expected: BigDecimal::try_from(12.0 * 0.005) - .unwrap() - .with_scale(18) - .to_unsigned_u256(), - }, - TestCase { - amount: BigDecimal::try_from(13.33) - .unwrap() - .with_scale(18) - .to_unsigned_u256(), - slippage: 0.3, - decimals: 18, - expected: BigDecimal::try_from(13.33 * 0.003) - .unwrap() - .with_scale(18) - .to_unsigned_u256(), - }, - TestCase { - amount: BigDecimal::try_from(13.33) - .unwrap() - .with_scale(6) - .to_unsigned_u256(), - slippage: 0.3, - decimals: 6, - expected: BigDecimal::try_from(13.33 * 0.003) - .unwrap() - .with_scale(6) - .to_unsigned_u256(), - }, - ]; - - for test_case in test_cases { - let result = - get_slippage_amount(test_case.amount, test_case.slippage, test_case.decimals); - assert_eq!(test_case.expected, result); - } - } -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs deleted file mode 100644 index 8694e04..0000000 --- a/src/utils/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod blockchain; -pub mod hidden; -pub mod math; -pub mod password; -pub mod resources; -pub mod scalar; -pub mod signing; diff --git a/src/utils/password.rs b/src/utils/password.rs deleted file mode 100644 index 6ca03e1..0000000 --- a/src/utils/password.rs +++ /dev/null @@ -1,142 +0,0 @@ -use crate::utils::hidden::Hidden; -use magic_crypt::{new_magic_crypt, MagicCryptTrait}; -use serde::{Deserialize, Serialize}; -use std::{error::Error, fmt, str::FromStr}; -use zeroize::Zeroize; -use zeroize::Zeroizing; - -pub const MFM_WALLET_PASSWORD: &str = "MFM_WALLET_PASSWORD"; - -/// A hidden string that implements [`Zeroize`]. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] -#[serde(transparent)] -pub struct SafePassword { - password: Hidden>, -} - -impl From for SafePassword { - fn from(s: String) -> Self { - Self { - password: Hidden::from(s.into_bytes().into_boxed_slice()), - } - } -} - -impl Drop for SafePassword { - fn drop(&mut self) { - self.password.zeroize(); - } -} - -impl SafePassword { - /// Gets a reference to bytes of a passphrase. - pub fn reveal(&self) -> &[u8] { - self.password.as_ref() - } -} - -/// An error for parsing a password from string. -#[derive(Debug)] -pub struct PasswordError; - -impl Error for PasswordError {} - -impl fmt::Display for PasswordError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "PasswordError") - } -} - -impl FromStr for SafePassword { - type Err = PasswordError; - - fn from_str(s: &str) -> Result { - Ok(Self::from(s.to_owned())) - } -} - -/// Gets the password provided by command line argument or environment variable if available. -/// Otherwise prompts for the password to be typed in. -pub fn get_or_prompt_password(env_password: Option) -> Result { - let env_value = match env_password { - Some(env_password) => std::env::var_os(env_password), - None => std::env::var_os(MFM_WALLET_PASSWORD), - }; - - if let Some(p) = env_value { - let env_password = p.into_string().map_err(|e| { - anyhow::anyhow!("failed to convert OsString into String, error: {:?}", e) - })?; - return Ok(env_password.into()); - } - - let password = prompt_password("Wallet password: ")?; - - Ok(password) -} - -pub fn prompt_password(prompt: &str) -> Result { - let password = loop { - let pass = rpassword::prompt_password(prompt) - .map_err(|e| anyhow::anyhow!("failed to convert OsString into String, error: {}", e))?; - if pass.is_empty() { - println!("Password cannot be empty!"); - continue; - } else { - break pass; - } - }; - - Ok(SafePassword::from(password)) -} - -pub fn decrypt_private_key( - password: SafePassword, - private_key: SafePassword, -) -> Result { - let str_password = { - let bytes = password.reveal().to_vec(); - Zeroizing::new(String::from_utf8(bytes).unwrap()) - }; - - let str_private_key = { - let bytes = private_key.reveal().to_vec(); - Zeroizing::new(String::from_utf8(bytes).unwrap()) - }; - - let mc = new_magic_crypt!(str_password, 256); - - match mc.decrypt_base64_to_string(str_private_key) { - Ok(s) => Ok(SafePassword::from(s)), - _ => Err(anyhow::anyhow!("invalid password")), - } -} - -pub fn encrypt_private_key_to_base64(password: SafePassword, private_key: SafePassword) -> String { - let str_password = { - let bytes = password.reveal().to_vec(); - Zeroizing::new(String::from_utf8(bytes).unwrap()) - }; - - let mc = new_magic_crypt!(str_password, 256); - - mc.encrypt_bytes_to_base64(private_key.reveal()) -} - -mod test { - #[test] - fn test_encrypt_decrypt() { - use super::{decrypt_private_key, encrypt_private_key_to_base64, SafePassword}; - - let password = SafePassword::from("some pass".to_string()); - let private_key = - SafePassword::from("10ED43C718714eb63d5aA57B78B54704E256024E".to_string()); - - let encrypted_base64 = encrypt_private_key_to_base64(password.clone(), private_key.clone()); - - let decrypted_private_key = - decrypt_private_key(password, SafePassword::from(encrypted_base64)).unwrap(); - - assert_eq!(private_key, decrypted_private_key) - } -} diff --git a/src/utils/resources.rs b/src/utils/resources.rs deleted file mode 100644 index 5fd97a1..0000000 --- a/src/utils/resources.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::path::Path; - -// It'll include the res.rs file generated by the build.rs, -// that include all resources in res/ folder inside the binary -// in the RES. -include!(concat!(env!("OUT_DIR"), "/res.rs")); - -// Returns a String of the file, trying first to look into the filesystem, -// if we cannot fint it, we try to find it in the RES that is some default -// resources compiled with the binary and are available in the res/ fold in the repo. -pub fn get_resource_file_fs_or_res(path: String) -> Option { - match std::fs::read_to_string(path.clone()) { - Ok(file_string) => Some(file_string), - Err(e) => { - tracing::debug!("get_resource_file_fs_or_res(): std::fs::read_to_string(path): Error: {}, trying on RES.", e); - - RES.get(path.as_str()).map(|s| s.to_string()) - } - } -} - -// Returns a bool if the file path exists in RES or fs. -pub fn exists_resource_file_fs_or_res(path: &str) -> bool { - RES.contains_key(path) || Path::new(path).exists() -} diff --git a/src/utils/scalar.rs b/src/utils/scalar.rs deleted file mode 100644 index 387cc8e..0000000 --- a/src/utils/scalar.rs +++ /dev/null @@ -1,577 +0,0 @@ -use num_bigint; -use serde::{self, Deserialize, Serialize}; -use std::convert::{TryFrom, TryInto}; -use std::fmt::{self, Display, Formatter}; -use std::ops::{Add, BitAnd, BitOr, Div, Mul, Rem, Sub}; -use std::str::FromStr; -use thiserror::Error; -use web3::types::*; - -pub use num_bigint::Sign as BigIntSign; - -// TODO: add BigDecimalError - -/// All operations on `BigDecimal` return a normalized value. -// Caveat: The exponent is currently an i64 and may overflow. See -// https://github.com/akubera/bigdecimal-rs/issues/54. -// Using `#[serde(from = "BigDecimal"]` makes sure deserialization calls `BigDecimal::new()`. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -#[serde(from = "bigdecimal::BigDecimal")] -pub struct BigDecimal(bigdecimal::BigDecimal); - -impl From for BigDecimal { - fn from(big_decimal: bigdecimal::BigDecimal) -> Self { - BigDecimal(big_decimal) - } -} - -impl BigDecimal { - /// These are the limits of IEEE-754 decimal128, a format we may want to switch to. See - /// https://en.wikipedia.org/wiki/Decimal128_floating-point_format. - pub const MIN_EXP: i32 = -6143; - pub const MAX_EXP: i32 = 6144; - pub const MAX_SIGNFICANT_DIGITS: i32 = 34; - - pub fn new(digits: BigInt, exp: i64) -> Self { - // bigdecimal uses `scale` as the opposite of the power of ten, so negate `exp`. - Self::from(bigdecimal::BigDecimal::new(digits.0, -exp)) - } - - pub fn with_scale(&self, new_scale: i64) -> BigDecimal { - Self::from(self.0.with_scale(new_scale)) - } - - pub fn from_unsigned_u256(n: &U256, scale: i64) -> Self { - let digits = BigInt::from_unsigned_u256(n); - Self::from(bigdecimal::BigDecimal::new(digits.0, scale)) - } - - pub fn from_signed_u256(n: &U256, scale: i64) -> Self { - let digits = BigInt::from_signed_u256(n); - Self::from(bigdecimal::BigDecimal::new(digits.0, scale)) - } - - pub fn parse_bytes(bytes: &[u8]) -> Option { - bigdecimal::BigDecimal::parse_bytes(bytes, 10).map(Self) - } - - pub fn zero() -> BigDecimal { - use bigdecimal::Zero; - - BigDecimal(bigdecimal::BigDecimal::zero()) - } - - pub fn as_bigint_and_exponent(&self) -> (num_bigint::BigInt, i64) { - self.0.as_bigint_and_exponent() - } - - pub fn abs(&self) -> BigDecimal { - BigDecimal::from(self.0.abs()) - } - - pub fn to_unsigned_u256(&self) -> U256 { - let (bigint, _) = self.as_bigint_and_exponent(); - BigInt::from(bigint).to_unsigned_u256() - } - - pub fn to_f64(&self) -> Option { - use bigdecimal::ToPrimitive; - self.normalized().0.to_f64() - } - - pub fn digits(&self) -> u64 { - self.0.digits() - } - - // Copy-pasted from `bigdecimal::BigDecimal::normalize`. We can use the upstream version once it - // is included in a released version supported by Diesel. - #[must_use] - pub fn normalized(&self) -> BigDecimal { - if self == &BigDecimal::zero() { - return BigDecimal::zero(); - } - - // Round to the maximum significant digits. - let big_decimal = self.0.with_prec(Self::MAX_SIGNFICANT_DIGITS as u64); - - let (bigint, exp) = big_decimal.as_bigint_and_exponent(); - let (sign, mut digits) = bigint.to_radix_be(10); - let trailing_count = digits.iter().rev().take_while(|i| **i == 0).count(); - digits.truncate(digits.len() - trailing_count); - let int_val = num_bigint::BigInt::from_radix_be(sign, &digits, 10).unwrap(); - let scale = exp - trailing_count as i64; - - BigDecimal(bigdecimal::BigDecimal::new(int_val, scale)) - } -} - -impl Display for BigDecimal { - fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { - self.0.fmt(f) - } -} - -impl fmt::Debug for BigDecimal { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "BigDecimal({})", self.0) - } -} - -impl FromStr for BigDecimal { - type Err = ::Err; - - fn from_str(s: &str) -> Result { - Ok(Self::from(bigdecimal::BigDecimal::from_str(s)?)) - } -} - -impl From for BigDecimal { - fn from(n: i32) -> Self { - Self::from(bigdecimal::BigDecimal::from(n)) - } -} - -impl From for BigDecimal { - fn from(n: i64) -> Self { - Self::from(bigdecimal::BigDecimal::from(n)) - } -} - -impl From for BigDecimal { - fn from(n: u64) -> Self { - Self::from(bigdecimal::BigDecimal::from(n)) - } -} - -impl TryFrom for BigDecimal { - type Error = anyhow::Error; - fn try_from(n: f64) -> Result { - Ok(Self::from(bigdecimal::BigDecimal::try_from(n).map_err( - |e| anyhow::anyhow!("from failed to f64, error: {}", e), - )?)) - } -} - -impl Add for BigDecimal { - type Output = Self; - - fn add(self, other: Self) -> Self { - Self::from(self.0.add(other.0)) - } -} - -impl Sub for BigDecimal { - type Output = Self; - - fn sub(self, other: Self) -> Self { - Self::from(self.0.sub(other.0)) - } -} - -impl Mul for BigDecimal { - type Output = Self; - - fn mul(self, other: Self) -> Self { - Self::from(self.0.mul(other.0)) - } -} - -impl Div for BigDecimal { - type Output = Self; - - fn div(self, other: Self) -> Self { - if other == BigDecimal::from(0) { - panic!("Cannot divide by zero-valued `BigDecimal`!") - } - - Self::from(self.0.div(other.0)) - } -} - -impl bigdecimal::ToPrimitive for BigDecimal { - fn to_i64(&self) -> Option { - self.0.to_i64() - } - fn to_u64(&self) -> Option { - self.0.to_u64() - } -} - -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] -pub struct BigInt(num_bigint::BigInt); - -#[derive(Error, Debug)] -pub enum BigIntOutOfRangeError { - #[error("Cannot convert negative BigInt into type")] - Negative, - #[error("BigInt value is too large for type")] - Overflow, -} - -impl<'a> TryFrom<&'a BigInt> for u64 { - type Error = BigIntOutOfRangeError; - fn try_from(value: &'a BigInt) -> Result { - let (sign, bytes) = value.to_bytes_le(); - - if sign == num_bigint::Sign::Minus { - return Err(BigIntOutOfRangeError::Negative); - } - - if bytes.len() > 8 { - return Err(BigIntOutOfRangeError::Overflow); - } - - // Replace this with u64::from_le_bytes when stabilized - let mut n = 0u64; - let mut shift_dist = 0; - for b in bytes { - n |= (b as u64) << shift_dist; - shift_dist += 8; - } - Ok(n) - } -} - -impl TryFrom for u64 { - type Error = BigIntOutOfRangeError; - fn try_from(value: BigInt) -> Result { - (&value).try_into() - } -} - -impl fmt::Debug for BigInt { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "BigInt({})", self) - } -} - -impl BigInt { - pub fn from_unsigned_bytes_le(bytes: &[u8]) -> Self { - BigInt(num_bigint::BigInt::from_bytes_le( - num_bigint::Sign::Plus, - bytes, - )) - } - - pub fn from_signed_bytes_le(bytes: &[u8]) -> Self { - BigInt(num_bigint::BigInt::from_signed_bytes_le(bytes)) - } - - pub fn from_signed_bytes_be(bytes: &[u8]) -> Self { - BigInt(num_bigint::BigInt::from_signed_bytes_be(bytes)) - } - - pub fn to_bytes_le(&self) -> (BigIntSign, Vec) { - self.0.to_bytes_le() - } - - pub fn to_bytes_be(&self) -> (BigIntSign, Vec) { - self.0.to_bytes_be() - } - - pub fn to_signed_bytes_le(&self) -> Vec { - self.0.to_signed_bytes_le() - } - - pub fn from_unsigned_u256(n: &U256) -> Self { - let mut bytes: [u8; 32] = [0; 32]; - n.to_little_endian(&mut bytes); - BigInt::from_unsigned_bytes_le(&bytes) - } - - pub fn from_signed_u256(n: &U256) -> Self { - let mut bytes: [u8; 32] = [0; 32]; - n.to_little_endian(&mut bytes); - BigInt::from_signed_bytes_le(&bytes) - } - - pub fn to_signed_u256(&self) -> U256 { - let bytes = self.to_signed_bytes_le(); - if self < &BigInt::from(0) { - assert!( - bytes.len() <= 32, - "BigInt value does not fit into signed U256" - ); - let mut i_bytes: [u8; 32] = [255; 32]; - i_bytes[..bytes.len()].copy_from_slice(&bytes); - U256::from_little_endian(&i_bytes) - } else { - U256::from_little_endian(&bytes) - } - } - - pub fn to_unsigned_u256(&self) -> U256 { - let (sign, bytes) = self.to_bytes_le(); - assert!( - sign == BigIntSign::NoSign || sign == BigIntSign::Plus, - "negative value encountered for U256: {}", - self - ); - U256::from_little_endian(&bytes) - } - - pub fn pow(self, exponent: u8) -> Self { - use num_traits::pow::Pow; - - BigInt(self.0.pow(&exponent)) - } - - pub fn bits(&self) -> usize { - self.0.bits().try_into().unwrap() - } -} - -impl Display for BigInt { - fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { - self.0.fmt(f) - } -} - -impl From for BigInt { - fn from(big_int: num_bigint::BigInt) -> BigInt { - BigInt(big_int) - } -} - -impl From for BigInt { - fn from(i: i32) -> BigInt { - BigInt(i.into()) - } -} - -impl From for BigInt { - fn from(i: u64) -> BigInt { - BigInt(i.into()) - } -} - -impl From for BigInt { - fn from(i: u8) -> BigInt { - BigInt(i.into()) - } -} - -impl From for BigInt { - fn from(i: i64) -> BigInt { - BigInt(i.into()) - } -} - -impl From for BigInt { - /// This implementation assumes that U64 represents an unsigned U64, - /// and not a signed U64 (aka int64 in Solidity). Right now, this is - /// all we need (for block numbers). If it ever becomes necessary to - /// handle signed U64s, we should add the same - /// `{to,from}_{signed,unsigned}_u64` methods that we have for U64. - fn from(n: U64) -> BigInt { - BigInt::from(n.as_u64()) - } -} - -impl From for BigInt { - /// This implementation assumes that U128 represents an unsigned U128, - /// and not a signed U128 (aka int128 in Solidity). Right now, this is - /// all we need (for block numbers). If it ever becomes necessary to - /// handle signed U128s, we should add the same - /// `{to,from}_{signed,unsigned}_u128` methods that we have for U256. - fn from(n: U128) -> BigInt { - let mut bytes: [u8; 16] = [0; 16]; - n.to_little_endian(&mut bytes); - BigInt::from_unsigned_bytes_le(&bytes) - } -} - -impl FromStr for BigInt { - type Err = ::Err; - - fn from_str(s: &str) -> Result { - num_bigint::BigInt::from_str(s).map(BigInt) - } -} - -impl Serialize for BigInt { - fn serialize(&self, serializer: S) -> Result { - self.to_string().serialize(serializer) - } -} - -impl<'de> Deserialize<'de> for BigInt { - fn deserialize>(deserializer: D) -> Result { - use serde::de::Error; - - let decimal_string = ::deserialize(deserializer)?; - BigInt::from_str(&decimal_string).map_err(D::Error::custom) - } -} - -impl Add for BigInt { - type Output = BigInt; - - fn add(self, other: BigInt) -> BigInt { - BigInt(self.0.add(other.0)) - } -} - -impl Sub for BigInt { - type Output = BigInt; - - fn sub(self, other: BigInt) -> BigInt { - BigInt(self.0.sub(other.0)) - } -} - -impl Mul for BigInt { - type Output = BigInt; - - fn mul(self, other: BigInt) -> BigInt { - BigInt(self.0.mul(other.0)) - } -} - -impl Div for BigInt { - type Output = BigInt; - - fn div(self, other: BigInt) -> BigInt { - if other == BigInt::from(0) { - panic!("Cannot divide by zero-valued `BigInt`!") - } - - BigInt(self.0.div(other.0)) - } -} - -impl Rem for BigInt { - type Output = BigInt; - - fn rem(self, other: BigInt) -> BigInt { - BigInt(self.0.rem(other.0)) - } -} - -impl BitOr for BigInt { - type Output = Self; - - fn bitor(self, other: Self) -> Self { - Self::from(self.0.bitor(other.0)) - } -} - -impl BitAnd for BigInt { - type Output = Self; - - fn bitand(self, other: Self) -> Self { - Self::from(self.0.bitand(other.0)) - } -} - -#[cfg(test)] -mod test { - use web3::types::U256; - - use super::{BigDecimal, BigInt}; - - #[test] - fn f64_bigdecimal() { - let test_cases = vec![ - (1.354, BigDecimal::try_from(1.354).unwrap(), "1.354"), - (11.0, BigDecimal::try_from(11).unwrap(), "11"), - (0.0, BigDecimal::try_from(0).unwrap(), "0"), - (0.33, BigDecimal::try_from(0.33).unwrap(), "0.33"), - (-0.33, BigDecimal::try_from(-0.33).unwrap(), "-0.33"), - ]; - - for (fnumber, fbigdecimal, snumber) in test_cases { - assert_eq!(fnumber, fbigdecimal.to_f64().unwrap()); - assert_eq!(fbigdecimal.normalized().to_string().as_str(), snumber); - } - } - - #[test] - #[warn(clippy::unnecessary_cast)] - fn u256_bigdecimal() { - let test_cases = vec![ - ( - U256::from(132397000000000000000_u128), - BigDecimal::from_unsigned_u256(&U256::from(132397000000000000000_u128), 18), - "132.397", - ), - ( - U256::from(9300002397000000000000000_u128), - BigDecimal::from_unsigned_u256(&U256::from(9300002397000000000000000_u128), 18), - "9300002.397", - ), - ]; - - for (n, nbigdecimal, snumber) in test_cases { - assert_eq!(n, nbigdecimal.to_unsigned_u256()); - assert_eq!(nbigdecimal.normalized().to_string().as_str(), snumber); - } - } - - #[test] - fn f64_u256() { - let test_cases = vec![ - ( - 132.397, - BigDecimal::try_from(132.397).unwrap(), - U256::from(132397000000000000000_u128), - 18, - ), - ( - 11.0, - BigDecimal::try_from(11).unwrap(), - U256::from(11000000000000000000_u128), - 18, - ), - ( - 0.33, - BigDecimal::try_from(0.33).unwrap(), - U256::from(330000000000000000_u128), - 18, - ), - ]; - - for (fnumber, fbigdecimal, nu256, decimal) in test_cases { - let bigdecimal_from_u256 = BigDecimal::from_unsigned_u256(&nu256, decimal); - assert_eq!(fbigdecimal.with_scale(decimal).to_unsigned_u256(), nu256); - assert_eq!(bigdecimal_from_u256.to_f64().unwrap(), fnumber); - } - } - - #[test] - fn normalize() { - let vals = vec![ - ( - BigDecimal::new(BigInt::from(10), -2), - BigDecimal(bigdecimal::BigDecimal::new(1.into(), 1)), - "0.1", - ), - ( - BigDecimal::new(BigInt::from(132400), 4), - BigDecimal(bigdecimal::BigDecimal::new(1324.into(), -6)), - "1324000000", - ), - ( - BigDecimal::new(BigInt::from(1_900_000), -3), - BigDecimal(bigdecimal::BigDecimal::new(19.into(), -2)), - "1900", - ), - (BigDecimal::new(0.into(), 3), BigDecimal::zero(), "0"), - (BigDecimal::new(0.into(), -5), BigDecimal::zero(), "0"), - ]; - - for (not_normalized, normalized, string) in vals { - assert_eq!(not_normalized.normalized(), normalized); - assert_eq!(not_normalized.normalized().to_string(), string); - assert_eq!(normalized.to_string(), string); - } - } - - #[test] - fn fmt_debug() { - let bi = BigInt::from(-17); - let bd = BigDecimal::new(bi.clone(), -2); - assert_eq!("BigInt(-17)", format!("{:?}", bi)); - assert_eq!("BigDecimal(-0.17)", format!("{:?}", bd)); - } -} diff --git a/src/utils/signing.rs b/src/utils/signing.rs deleted file mode 100644 index 81de09b..0000000 --- a/src/utils/signing.rs +++ /dev/null @@ -1,11 +0,0 @@ -use secp256k1::PublicKey; -use web3::{signing::keccak256, types::Address}; - -pub fn public_key_address(public_key: &PublicKey) -> Address { - let public_key = public_key.serialize_uncompressed(); - - debug_assert_eq!(public_key[0], 0x04); - let hash = keccak256(&public_key[1..]); - - Address::from_slice(&hash[12..]) -} diff --git a/src/watcher/cmd.rs b/src/watcher/cmd.rs deleted file mode 100644 index e189102..0000000 --- a/src/watcher/cmd.rs +++ /dev/null @@ -1,15 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("watcher") - .about("Watch an address") - .arg( - clap::arg!(-n --"network" "Network to use, ex (bsc, polygon)").required(true), - ) - .arg(clap::arg!(-a --"address"

"Address to watch").required(true)) -} - -#[tracing::instrument(name = "track call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/watcher/mod.rs b/src/watcher/mod.rs deleted file mode 100644 index b40bb62..0000000 --- a/src/watcher/mod.rs +++ /dev/null @@ -1,72 +0,0 @@ -use crate::{cmd::helpers, config::Config, notification::notify_all}; - -use clap::ArgMatches; -use futures::StreamExt; -use std::time::Duration; -use web3::types::BlockId; - -pub mod cmd; - -#[tracing::instrument(name = "wrapped run watcher")] -async fn wrapped_run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let notifiers = Config::global() - .notifications - .as_ref() - .unwrap() - .all_notifiers(); - - let address = helpers::get_address(args)?; - let network = helpers::get_network(args)?; - - let url = match network.node_url() { - Some(url) => url, - None => return Err(anyhow::anyhow!("node_url_http is missing")), - }; - - let web3 = network.get_web3_client_http(url.as_str())?; - - let filter = web3.eth_filter().create_blocks_filter().await.unwrap(); - - let logs_stream = filter.stream(Duration::from_secs(1)); - futures::pin_mut!(logs_stream); - - loop { - // Process new blocks as they arrive - let block_hash = logs_stream.next().await.unwrap().unwrap(); - - // Get the block number and retrieve the block - let block_id = BlockId::Hash(block_hash); - let block = web3.eth().block(block_id).await.unwrap().unwrap(); - - // Filter the transactions in the block for those related to the address - let transactions = block.transactions; - - for tx_hash in transactions { - let txn = web3 - .eth() - .transaction(web3::types::TransactionId::Hash(tx_hash)) - .await - .unwrap() - .unwrap(); - - match (txn.to, txn.from) { - (Some(to), Some(from)) if to == address || from == address => { - notify_all(¬ifiers, format!("MFM [watcher]: matches the filter of address ({}) in the transaction hash ({}), found with from ({}) and to ({}), value of {:.18} and gas_price of {}.\n", address, tx_hash, from, to, txn.value, txn.gas_price.unwrap())).unwrap(); - } - _ => continue, - } - } - } -} - -#[tracing::instrument(name = "run watcher")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - loop { - match wrapped_run(args).await { - Ok(_) => {} - Err(e) => tracing::error!("ignored by watcher, error running wrapped_run(): {:?}", e), - } - let duration = std::time::Duration::from_secs(1); - std::thread::sleep(duration); - } -} diff --git a/src/withdraw/cmd.rs b/src/withdraw/cmd.rs deleted file mode 100644 index 0924fa8..0000000 --- a/src/withdraw/cmd.rs +++ /dev/null @@ -1,29 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("withdraw") - .about("Withdraw to a wallet") - .arg( - clap::arg!(-w --"wallet" "Wallet id from config file") - .required(true), - ) - .arg(clap::arg!(-n --"network" "Network to use, ex (bsc, polygon)").required(true)) - .arg( - clap::arg!(-t --"withdraw-wallet" "Withdraw wallet to receive the transfer") - .required(true), - ) - .arg( - clap::arg!(-a --"asset" "Asset to withdraw") - .required(true) - ) - .arg( - clap::arg!(-v --"amount" "Amount to withdraw") - .required(true) - .value_parser(clap::value_parser!(f64)) - ) -} - -#[tracing::instrument(name = "withdraw call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/withdraw/mod.rs b/src/withdraw/mod.rs deleted file mode 100644 index 555b32b..0000000 --- a/src/withdraw/mod.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::cmd::helpers; -use clap::ArgMatches; - -pub mod cmd; - -#[tracing::instrument(name = "run withdraw")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let wallet = helpers::get_wallet(args).unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - let withdraw_wallet = helpers::get_withdraw_wallet(args); - - let network = helpers::get_network(args).unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - let asset = helpers::get_asset_in_network_from_args(args, network.name()); - let asset_decimals = asset.decimals().await.unwrap(); - let amount = helpers::get_amount(args, asset_decimals).unwrap_or_else(|e| { - tracing::error!(error = %e); - panic!() - }); - - asset - .withdraw(wallet, &withdraw_wallet, amount) - .await - .unwrap(); - - Ok(()) -} diff --git a/src/wrap/cmd.rs b/src/wrap/cmd.rs deleted file mode 100644 index 4719611..0000000 --- a/src/wrap/cmd.rs +++ /dev/null @@ -1,24 +0,0 @@ -use clap::{ArgMatches, Command}; - -pub fn generate() -> Command { - Command::new("wrap") - .about("Wrap a coin to a token") - .arg( - clap::arg!(-n --"network" "Network to wrap coin to token") - .required(true), - ) - .arg( - clap::arg!(-w --"wallet" "Wallet id from config file") - .required(true), - ) - .arg( - clap::arg!(-a --"amount" "Amount to wrap coin into token, default: (balance-min_balance_coin)") - .required(false) - .value_parser(clap::value_parser!(f64)), - ) -} - -#[tracing::instrument(name = "wrap call command")] -pub async fn call_sub_commands(args: &ArgMatches) -> Result<(), anyhow::Error> { - super::run(args).await -} diff --git a/src/wrap/mod.rs b/src/wrap/mod.rs deleted file mode 100644 index a0bdade..0000000 --- a/src/wrap/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::cmd::helpers; -use clap::ArgMatches; - -pub mod cmd; - -#[tracing::instrument(name = "run wrap")] -async fn run(args: &ArgMatches) -> Result<(), anyhow::Error> { - let network = helpers::get_network(args)?; - let wallet = helpers::get_wallet(args)?; - - let wrapped_asset = network.get_wrapped_asset()?; - let wrapped_asset_decimals = wrapped_asset.decimals().await?; - - let amount_in = helpers::get_amount(args, wrapped_asset_decimals)?; - - wrapped_asset.wrap(wallet, amount_in).await -} diff --git a/test_config.yaml b/test_config.yaml deleted file mode 100644 index c3b28e4..0000000 --- a/test_config.yaml +++ /dev/null @@ -1,321 +0,0 @@ -server: - api_url: http://127.0.0.1:8000 - api_token: 04e802e3-4a66-4ad6-acb9-ae184673ad55 - -wallets: - test-wallet: - private_key: YOUR_PRIVATE_KEY - farm-wallet: - private_key: YOUR_PRIVATE_KEY - -withdraw_wallets: - test-wallet2: - address: YOUR_PUBLIC_ADDRESS - -networks: - bsc: - name: bsc - symbol: bnb - chain_id: 56 - rpc_url: https://bsc-dataseed.binance.org - blockexplorer_url: https://bscscan.com - min_balance_coin: 0.1 - wrapped_asset: wbnb - decimals: 18 - polygon: - name: polygon - symbol: matic - chain_id: 137 - rpc_url: https://polygon-rpc.com/ - blockexplorer_url: https://polygonscan.com/ - min_balance_coin: 1 - wrapped_asset: wmatic - decimals: 18 - -exchanges: - pancake_swap_v2: - name: pancake_swap_v2 - router_address: 0x10ED43C718714eb63d5aA57B78B54704E256024E - factory_address: 0xca143ce32fe78f1f7019d7d551a6402fc5350c73 - network_id: bsc - quickswap_v2: - name: quickswap_v2 - router_address: 0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff - factory_address: 0x5757371414417b8c6caad45baef941abc7d3ab32 - network_id: polygon - sushi_swap_polygon: - name: sushi_swap_polygon - router_address: 0x1b02da8cb0d097eb8d57a175b88c7d8b47997506 - factory_address: 0xc35dadb65012ec5796536bd9864ed8773abc74c4 - network_id: polygon - biswap: - name: biswap - router_address: 0x3a6d8ca21d1cf76f653a67577fa0d27453350dd8 - factory_address: 0x858e3312ed3a876947ea49d572a7c42de08af7ee - network_id: bsc - -assets: - qidao: - kind: token - networks: - polygon: - name: qidao - network_id: polygon - address: 0x580a84c73811e1839f75d86d75d88cca0c241ff4 - slippage: 2 - path_asset: weth - dquick: - kind: token - networks: - polygon: - name: dquick - network_id: polygon - address: 0xf28164a485b0b2c90639e47b0f377b4a438a16b1 - slippage: 2 - path_asset: weth - xrp: - kind: token - networks: - bsc: - name: xrp - network_id: bsc - address: 0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE - slippage: 2 - path_asset: wbnb - link: - kind: token - networks: - bsc: - name: link - network_id: bsc - address: 0xF8A0BF9cF54Bb92F17374d9e9A321E6a111a51bD - slippage: 2 - path_asset: wbnb - gala: - kind: token - networks: - bsc: - name: gala - network_id: bsc - address: 0x7dDEE176F665cD201F93eEDE625770E2fD911990 - slippage: 2 - path_asset: wbnb - near: - kind: token - networks: - bsc: - name: near - network_id: bsc - address: 0x1Fa4a73a3F0133f0025378af00236f3aBDEE5D63 - slippage: 2 - path_asset: wbnb - luna: - kind: token - networks: - bsc: - name: luna - network_id: bsc - address: 0x156ab3346823B651294766e23e6Cf87254d68962 - slippage: 2 - path_asset: wbnb - wmatic: - kind: token - networks: - bsc: - name: wmatic - network_id: bsc - address: 0xcc42724c6683b7e57334c4e856f4c9965ed682bd - slippage: 2 - path_asset: wbnb - polygon: - name: wmatic - network_id: polygon - address: 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270 - slippage: 2 - path_asset: weth - anonq: - kind: token - networks: - bsc: - name: anonq - network_id: bsc - address: 0xf393138616cd6DD367171eaA59c2eaEE420a32b9 - slippage: 2 - path_asset: wbnb - busd: - kind: token - networks: - bsc: - name: busd - network_id: bsc - address: 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56 - slippage: 2 - path_asset: wbnb - wbnb: - kind: token - networks: - bsc: - name: wbnb - network_id: bsc - address: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c - slippage: 2 - path_asset: wbnb - weth: - kind: token - networks: - bsc: - name: weth - network_id: bsc - address: 0x2170ed0880ac9a755fd29b2688956bd959f933f8 - slippage: 2 - path_asset: wbnb - polygon: - name: weth - network_id: polygon - address: 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619 - slippage: 2 - path_asset: weth - btc: - kind: token - networks: - bsc: - name: btc - network_id: bsc - address: 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c - slippage: 2 - path_asset: wbnb - sol: - kind: token - networks: - bsc: - name: sol - network_id: bsc - address: 0x570A5D26f7765Ecb712C0924E4De545B89fD43dF - slippage: 2 - path_asset: wbnb - polygon: - name: sol - network_id: polygon - address: 0x7dff46370e9ea5f0bad3c4e29711ad50062ea7a4 - slippage: 2 - path_asset: weth - posi: - kind: token - networks: - bsc: - name: posi - network_id: bsc - address: 0x5ca42204cdaa70d5c773946e69de942b85ca6706 - slippage: 2 - path_asset: wbnb - cake: - kind: token - networks: - bsc: - name: cake - network_id: bsc - address: 0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82 - slippage: 2 - path_asset: wbnb - pacoca: - kind: token - networks: - bsc: - name: pacoca - network_id: bsc - address: 0x55671114d774ee99d653d6c12460c780a67f1d18 - slippage: 1 - path_asset: wbnb - safemoon: - kind: token - networks: - bsc: - name: safemoon - network_id: bsc - address: 0x42981d0bfbAf196529376EE702F2a9Eb9092fcB5 - slippage: 1 - path_asset: wbnb - grt: - kind: token - networks: - polygon: - name: grt - network_id: polygon - address: 0x5fe2b58c013d7601147dcdd68c143a77499f5531 - slippage: 1 - path_asset: weth - usdc: - kind: token - networks: - polygon: - name: usdc - network_id: polygon - address: 0x2791bca1f2de4661ed88a30c99a7a9449aa84174 - slippage: 1 - path_asset: wmatic - bsc: - name: usdc - network_id: bsc - address: 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d - slippage: 1 - path_asset: wbnb - usdt: - kind: token - networks: - bsc: - name: usdt - network_id: bsc - address: 0x55d398326f99059ff775485246999027b3197955 - slippage: 1 - path_asset: wbnb - baby: - kind: token - networks: - bsc: - name: baby - network_id: bsc - address: 0x53e562b9b7e5e94b81f10e96ee70ad06df3d2657 - slippage: 1 - path_asset: usdt - bal: - kind: token - networks: - polygon: - name: bal - network_id: polygon - address: 0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3 - slippage: 3 - path_asset: weth - avax: - kind: token - networks: - polygon: - name: avax - network_id: polygon - address: 0x2c89bbc92bd86f8075d1decc58c7f4e0107f286b - slippage: 2 - path_asset: weth - -rebalancers: - test-rebalancer: - name: test-anonq-busd - network_id: bsc - wallet_id: test-wallet - portfolio: - anonq: - percent: 40 - busd: - percent: 25 - wbnb: - percent: 25 - eth: - percent: 5 - btc: - percent: 5 - strategy: full_parking #diff_parking - # if zero, always run - threshold_percent: 2 - quoted_in: busd - parking_asset_id: busd - parking_asset_min_move: 0.01 - diff --git a/tests/blockchains/gethnet/Dockerfile b/tests/blockchains/gethnet/Dockerfile deleted file mode 100644 index 4159236..0000000 --- a/tests/blockchains/gethnet/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ethereum/client-go:stable-arm64 - -RUN apk --no-cache add curl - -COPY password.txt /root/config/password.txt -COPY genesis.json /root/config/genesis.json -COPY data/keystore /root/.ethereum/devchain/keystore - -EXPOSE 8545 -EXPOSE 8546 - -RUN geth init /root/config/genesis.json - -HEALTHCHECK --interval=10s --timeout=20s --retries=6 \ - CMD curl --fail http://localhost:8545 -X POST -H 'Content-Type: application/json' \ - --data '{"jsonrpc":"2.0", "method":"net_listening", "param":[], "id": 11077}' || exit 1 - - -ENTRYPOINT [ "geth", "--dev", "--dev.period", "1", "--miner.gaslimit", "30000000", "--password", \ - "/root/config/password.txt", "--datadir", "/root/.ethereum/devchain", "--mine", "--ipcdisable", \ - "--http", "--http.api", "eth,web3,personal,net,txpool", "--http.addr", "0.0.0.0", "--http.port=8545", "--http.corsdomain", "*", \ - "--ws", "--ws.origins", "*", "--ws.addr", "0.0.0.0", "--ws.port=8546", "--graphql", "--graphql.corsdomain", "*", \ - "--authrpc.vhosts", "*", "--http.vhosts", "*", \ - "--allow-insecure-unlock", "--rpc.allow-unprotected-txs", "--vmdebug", "--networkid=11077", "--rpc.txfeecap", "0", \ - "--unlock", "0x4E22e05C29A7165Aeee0D813bE03Af17F129A2d1" \ -] \ No newline at end of file diff --git a/tests/blockchains/gethnet/data/keystore/UTC--2023-03-28T01-13-34.803419000Z--4e22e05c29a7165aeee0d813be03af17f129a2d1 b/tests/blockchains/gethnet/data/keystore/UTC--2023-03-28T01-13-34.803419000Z--4e22e05c29a7165aeee0d813be03af17f129a2d1 deleted file mode 100644 index f309cc1..0000000 --- a/tests/blockchains/gethnet/data/keystore/UTC--2023-03-28T01-13-34.803419000Z--4e22e05c29a7165aeee0d813be03af17f129a2d1 +++ /dev/null @@ -1 +0,0 @@ -{"address":"4e22e05c29a7165aeee0d813be03af17f129a2d1","crypto":{"cipher":"aes-128-ctr","ciphertext":"d3fe9489a82ad8d12df93c6d0bca170399111093618f39cb04f824f6133b4c1d","cipherparams":{"iv":"82e3cdede98dfd3ce3b3ad7c2897dfbf"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"2a84c7b11bdbf88a8bedfad0861e33bc71e764be950d63c9bbef7d02ab91a940"},"mac":"36e97f89063c7f358d4c525b817eea20fb23d4799129f57c66c049851606f63a"},"id":"6f08ebc7-b4a7-43a5-8e72-482ded6e58ae","version":3} \ No newline at end of file diff --git a/tests/blockchains/gethnet/genesis.json b/tests/blockchains/gethnet/genesis.json deleted file mode 100644 index fa4c53d..0000000 --- a/tests/blockchains/gethnet/genesis.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "config": { - "chainId": 11077, - "homesteadBlock": 0, - "eip150Block": 0, - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "berlinBlock": 0, - "ethash": {} - }, - "difficulty": "1", - "gasLimit": "8000000", - "alloc": { - "0x4E22e05C29A7165Aeee0D813bE03Af17F129A2d1": { - "balance": "3000000000000000" - } - } -} diff --git a/tests/blockchains/gethnet/password.txt b/tests/blockchains/gethnet/password.txt deleted file mode 100644 index e69de29..0000000 diff --git a/tests/common.rs b/tests/common.rs deleted file mode 100644 index 2ad8d7a..0000000 --- a/tests/common.rs +++ /dev/null @@ -1,57 +0,0 @@ -use clap::{ArgMatches, Command}; -use once_cell::sync::Lazy; - -use mfm::{ - cmd, - config::Config, - telemetry::{get_subscriber, init_subscriber}, -}; - -const APP_NAME: &str = "integration_test"; -const DEFAULT_LOG_LEVEL: &str = "debug"; -const DEFAULT_CONFIG_FILE: &str = "test_config.yaml"; - -static TRACING: Lazy<()> = Lazy::new(|| { - let subscriber = get_subscriber(APP_NAME.into(), DEFAULT_LOG_LEVEL.into(), std::io::stdout); - init_subscriber(subscriber); -}); - -pub struct App { - _command: Command, - config: Config, -} - -impl App { - // TODO: impl all configs as builders here - pub fn new() -> Self { - Self::default() - } - - pub fn _command(&self) -> Command { - self._command.clone() - } - - pub fn config(&self) -> Config { - self.config.clone() - } - - pub fn _get_arg_matches(&self, argv: &'static str) -> ArgMatches { - _get_arg_matches(self._command(), argv) - } -} - -impl Default for App { - fn default() -> Self { - Lazy::force(&TRACING); - - App { - _command: cmd::new(), - config: Config::from_file(DEFAULT_CONFIG_FILE).unwrap(), - } - } -} - -pub fn _get_arg_matches(cmd: Command, argv: &'static str) -> ArgMatches { - cmd.try_get_matches_from(argv.split(' ').collect::>()) - .unwrap() -} diff --git a/tests/network.rs b/tests/network.rs deleted file mode 100644 index 2192ce1..0000000 --- a/tests/network.rs +++ /dev/null @@ -1,66 +0,0 @@ -mod common; - -use common::App; -use mfm::asset::Asset; -use web3::types::U256; - -#[tokio::test] -async fn test_get_exchange_by_liquidity() { - struct TestCase { - network_name: &'static str, - input_asset_name: &'static str, - output_asset_name: &'static str, - exchange_expected: &'static str, - } - - let app = App::new(); - let config = app.config(); - - let test_cases = vec![ - TestCase { - network_name: "polygon", - input_asset_name: "usdc", - output_asset_name: "bal", - exchange_expected: "sushi_swap_polygon", - }, - TestCase { - network_name: "polygon", - input_asset_name: "usdc", - output_asset_name: "sol", - exchange_expected: "quickswap_v2", - }, - ]; - - for test_case in test_cases { - let network = config.networks.get(test_case.network_name).unwrap(); - - let input_asset_config = config.assets.get(test_case.input_asset_name).unwrap(); - let input_asset_assets: Vec = input_asset_config - .assets_list_by_network() - .unwrap() - .into_iter() - .filter(|a| a.network_id() == test_case.network_name) - .collect(); - - let input_asset = input_asset_assets.last().unwrap(); - - let output_asset_config = config.assets.get(test_case.output_asset_name).unwrap(); - let output_asset_assets: Vec = output_asset_config - .assets_list_by_network() - .unwrap() - .into_iter() - .filter(|a| a.network_id() == test_case.network_name) - .collect(); - - let output_asset = output_asset_assets.last().unwrap(); - - let amount_in = U256::exp10(18); - - let exchange = network - .get_exchange_by_liquidity(input_asset, output_asset, amount_in) - .await - .unwrap(); - - assert_eq!(exchange.name(), test_case.exchange_expected); - } -}