-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
856b9e9
commit 56814ff
Showing
6 changed files
with
142 additions
and
12 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::sync::Arc; | ||
|
||
use ethers::signers::LocalWallet; | ||
use hyperliquid::{ | ||
types::{exchange::request::TwapRequest, Chain}, | ||
utils::parse_size, | ||
Exchange, Hyperliquid, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Key was randomly generated for testing and shouldn't be used with any real funds | ||
let wallet: Arc<LocalWallet> = Arc::new( | ||
"e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e" | ||
.parse() | ||
.unwrap(), | ||
); | ||
|
||
let exchange: Exchange = Hyperliquid::new(Chain::Dev); | ||
|
||
let asset = 0; | ||
let sz_decimals = 2; | ||
|
||
let twap = TwapRequest { | ||
asset, | ||
is_buy: true, | ||
reduce_only: false, | ||
minutes: 10, | ||
sz: parse_size(13.85, sz_decimals), | ||
randomize: true, | ||
}; | ||
|
||
let vault_address = None; | ||
|
||
println!("Placing a TWAP order..."); | ||
let response = exchange | ||
.twap_order(wallet.clone(), twap, vault_address) | ||
.await | ||
.expect("Failed to place twap order"); | ||
|
||
println!("Response: {:?}", response); | ||
} |
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