-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OBv2: Update orderbook test
- Loading branch information
Showing
2 changed files
with
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
# Serum in SolanaJ | ||
A SolanaJ module for interfacing with the Serum DEX. | ||
# solanaj-programs - OpenBook v2 | ||
A SolanaJ module for interfacing with the OpenBook v2 DEX. | ||
## Code Examples | ||
|
||
### Get Orderbook | ||
### Get SOL/USDC Orderbook | ||
```java | ||
final PublicKey solUsdcPublicKey = new PublicKey("7xMDbYTCqQEcK2aM9LbetGtNFJpzKdfXzLL5juaLh4GJ"); | ||
final Market solUsdcMarket = new MarketBuilder() | ||
.setClient(new RpcClient()) | ||
.setPublicKey(solUsdcPublicKey) | ||
.setRetrieveOrderBooks(true) | ||
.build(); | ||
|
||
final OrderBook bids = solUsdcMarket.getBidOrderBook(); | ||
// SOL/USDC | ||
RpcClient client = new RpcClient("YOUR_RPC_HOST"); | ||
OpenBookManager openBookManager = new OpenBookManager(client); | ||
|
||
OpenBookMarket solUsdc = openBookManager.getMarket( | ||
PublicKey.valueOf("C3YPL3kYCSYKsmHcHrPWx1632GUXGqi2yMXJbfeCc57q"), | ||
false, | ||
true | ||
).get(); | ||
|
||
log.info("Bids: {}", solUsdc.getBidOrders()); | ||
log.info("Asks: {}", solUsdc.getAskOrders()); | ||
|
||
assertFalse(solUsdc.getBidOrders().isEmpty()); | ||
``` | ||
```text | ||
[main] INFO OpenBookTest - Bids: [OpenBookOrder(price=67.6, size=0.007, trader=FsQhJepwFkqsghZ3fiCRNCP7qEQk3BVcwPiCJCza3MsB), OpenBookOrder(price=69.0, size=0.002, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX), OpenBookOrder(price=65.0, size=0.046, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX), OpenBookOrder(price=50.0, size=0.1, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX), OpenBookOrder(price=2.0, size=0.181, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX)] | ||
[main] INFO OpenBookTest - Asks: [OpenBookOrder(price=80.0, size=0.1, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX), OpenBookOrder(price=200.0, size=1.0, trader=4gpeoTcx9awU7cHWWZugRe1scHot5wZdCwyc5xLYQn5T), OpenBookOrder(price=86.0, size=0.02, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX), OpenBookOrder(price=85.0, size=0.01, trader=9SMAjQPumpCPJNRakX1ofdgJ736Fz7TN6ywsurj789ZX)] | ||
``` | ||
|
||
### Get All Markets | ||
```java | ||
RpcClient client = new RpcClient("YOUR_RPC_HOST"); | ||
|
||
OpenBookManager openBookManager = new OpenBookManager(client); | ||
log.info("Market cache: {}", openBookManager.getOpenBookMarkets()); | ||
``` |
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