Skip to content

Commit

Permalink
Phoenix tests: Add JitoSol test
Browse files Browse the repository at this point in the history
  • Loading branch information
skynetcap committed Nov 19, 2023
1 parent 8ad5c62 commit 892be41
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions phoenix/src/test/java/PhoenixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ public void phoenixGetMarketsTest() throws RpcException {
});
}

@Test
public void phoenixGetJitoSolMarketTest() throws RpcException {
final AccountInfo marketAccountInfo = client.getApi().getAccountInfo(
new PublicKey("2t9TBYyUyovhHQq434uAiBxW6DmJCg7w4xdDoSK6LRjP"),
Map.of("commitment", Commitment.PROCESSED)
);

byte[] data = marketAccountInfo.getDecodedData();
PhoenixMarketHeader header = PhoenixMarketHeader.readPhoenixMarketHeader(data);
PhoenixMarket phoenixMarket = PhoenixMarket.readPhoenixMarket(data, header);

var asks = phoenixMarket.getAskListSanitized().stream().sorted(
(o1, o2) -> Math.toIntExact(o2.component1().getPriceInTicks() - o1.getFirst().getPriceInTicks())
).toList();
asks.forEach(fifoOrderIdFIFORestingOrderPair -> {
log.info(String.format("Ask: $%.2f, Size: %.2f SOL, Trader: %s",
(double) fifoOrderIdFIFORestingOrderPair.getFirst().getPriceInTicks() / phoenixMarket.getTickSizeInQuoteLotsPerBaseUnit(),
(double) fifoOrderIdFIFORestingOrderPair.getSecond().getNumBaseLots() / phoenixMarket.getBaseLotsPerBaseUnit(),
phoenixMarket.getTradersSanitized().get((int) (fifoOrderIdFIFORestingOrderPair.getSecond().getTraderIndex() - 1)).getFirst().toBase58()));
});

var bids = phoenixMarket.getBidListSanitized().stream().sorted(
(o1, o2) -> Math.toIntExact(o2.component1().getPriceInTicks() - o1.getFirst().getPriceInTicks())
).toList();
bids.forEach(fifoOrderIdFIFORestingOrderPair -> {
log.info(String.format("Bid: $%.2f, Size: %.2f SOL, Trader: %s",
(double) fifoOrderIdFIFORestingOrderPair.getFirst().getPriceInTicks() / phoenixMarket.getTickSizeInQuoteLotsPerBaseUnit(),
(double) fifoOrderIdFIFORestingOrderPair.getSecond().getNumBaseLots() / phoenixMarket.getBaseLotsPerBaseUnit(),
phoenixMarket.getTradersSanitized().get((int) (fifoOrderIdFIFORestingOrderPair.getSecond().getTraderIndex() - 1)).getFirst().toBase58()));
});
}

@Test
public void phoenixGetMarketDetailTest() throws RpcException, IOException {
final AccountInfo marketAccountInfo = client.getApi().getAccountInfo(
Expand Down

0 comments on commit 892be41

Please sign in to comment.