-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update readme + formatter to use num_format, remvoe last ts files
- Loading branch information
Showing
8 changed files
with
109 additions
and
168 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,95 @@ | ||
# StarkWhaleAlert | ||
|
||
Project | ||
Make a tweet when transfer of at leasst X | ||
uses alchemy RPC get_Events | ||
starknetJS | ||
coincap io conversion token <=> $ value https://docs.coincap.io/ | ||
[![Twitter URL](https://img.shields.io/twitter/url.svg?label=Follow%20%40StarkWhaleAlert&style=social&url=https%3A%2F%2Ftwitter.com%2FStarkWhaleAlert)]( https://twitter.com/StarkWhaleAlert) | ||
|
||
This is a script aimed to track all transfers above a threshold done on Starknet. | ||
If such a transfer is detected it'll post a tweet. | ||
|
||
## Overview | ||
|
||
Here is how the script works: | ||
1. Fetch last processed block number from file and the last block produced by the network. | ||
- If no new block ⇒ Stop | ||
- If it is too much behind ⇒ Stop: probably something went wrong. | ||
- Otherwise ⇒ Continue | ||
2. For each token: | ||
1. Get all `Transfer` events from last processed block to current network block. | ||
2. Filter events to only keep the ones above the threshold: | ||
- If none ⇒ Proceed to next token | ||
- If any ⇒ Tweet | ||
3. Set last processed block to last block produced by the network | ||
|
||
|
||
To create the tweet the text needs to be formatted involving multiple steps: | ||
- Format the token value | ||
- Fetch it's USD value and format it | ||
- Format the from and to: | ||
- Can be bridging to L1 | ||
- Can be bridging to L2 | ||
- Can be someone with a StarknetID | ||
- Can be one of the known addresses (e.g.: Layerswap, Jediswap, ...) | ||
- If none of the previous ⇒ Shorten the address to have something like `0x123...4567` | ||
- Put a reference to the transaction involving the transfer available on a block explorer | ||
|
||
|
||
## Installation | ||
use `cargo install --path crates/crate-name` | ||
**Prerequisite: have Rust and Cargo installed** | ||
|
||
Build both binaries: | ||
```shell | ||
cargo build | ||
``` | ||
|
||
Run a specific binary using: | ||
```shell | ||
cargo run --bin bin_name | ||
``` | ||
|
||
Build for a linux environment from a mac using: | ||
```shell | ||
cargo build --bin starkwhale_alert --release --target=x86_64-unknown-linux-gnu | ||
``` | ||
|
||
## Setup | ||
|
||
First create a new project on: | ||
https://developer.twitter.com/en/portal/dashboard | ||
Remember to save the `CLIENT_ID` and `CLIENT_SECRET` somehwere, you'll need it later. | ||
In the **App info** section fill the Callback URI with `http://127.0.0.1:3000/callback`. | ||
You can fill the required `Website URL` with anything you want it doesn't matter. | ||
|
||
build for linux: `cargo build --bin starkwhale_alert --release --target=x86_64-unknown-linux-gnu` | ||
Then run: | ||
```shell | ||
cargo run --bin twitter_login | ||
``` | ||
You can now open http://127.0.0.1:3000/login in your browser and authorize the application. It should redirect you to a page where you can see your token. Copy the whole page, create a file named `token.json` in the [db folder](./db/) and paste inside that file. | ||
|
||
### Setup the .env | ||
This script is using: | ||
- Infura as a node provider | ||
- Coincap to fetch the USD value of a token | ||
- Here is where you paste the twitter `CLIENT_ID` and `CLIENT_SECRET` | ||
|
||
Feel free to tweak the code to use another RPC or API to fetch the USD value. | ||
|
||
## Contribution | ||
### Run the bot | ||
Once everything is setup you can try the bot using: | ||
```shell | ||
cargo run --bin starkwhale_alert | ||
``` | ||
|
||
analyse is there to help and analyse a token to find out what would be the best lower bound | ||
Strict minimum to work with | ||
If you want to build the binary, add the release flag: | ||
```shell | ||
cargo build --bin starkwhale_alert --release | ||
``` | ||
You can now find the binary at `./target/release/starkwhale_alert` | ||
|
||
## TODO | ||
The first time you run the script, the block might be out of date and it'll tell you to restart the script using an option: | ||
```shell | ||
./starkwhale_alert -s | ||
``` | ||
This will update the block file to the latest block. | ||
|
||
- Have a DB with a correspondancy wallet address <==> to actual (like binance, starkgate, 0x0, etc etc,) | ||
- A way of automatically adjusting the threshold? | ||
After this step you are all setup. | ||
I setup nodecron to run this script every 5 minutes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"last_processed_block": 364110 | ||
"last_processed_block": 389785 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.