Skip to content

Commit

Permalink
Phoenix: add PhoenixMarket
Browse files Browse the repository at this point in the history
  • Loading branch information
skynetcap committed Nov 19, 2023
1 parent f4e0723 commit e395937
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mmorrell.phoenix.model;

import lombok.Builder;
import lombok.Data;
import org.bitcoinj.core.Utils;

@Data
@Builder
public class PhoenixMarket {

private static final int START_OFFSET = 832;
private long baseLotsPerBaseUnit;
private long tickSizeInQuoteLotsPerBaseUnit;

public static PhoenixMarket readPhoenixMarket(byte[] data) {
PhoenixMarket phoenixMarket = PhoenixMarket.builder()
.baseLotsPerBaseUnit(Utils.readInt64(data, START_OFFSET))
.tickSizeInQuoteLotsPerBaseUnit(Utils.readInt64(data, START_OFFSET + 8))
.build();

return phoenixMarket;
}

}
3 changes: 3 additions & 0 deletions phoenix/src/test/java/PhoenixTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.google.common.io.Files;
import com.google.common.io.Resources;
import com.mmorrell.phoenix.model.PhoenixMarket;
import com.mmorrell.phoenix.model.PhoenixMarketHeader;
import com.mmorrell.phoenix.program.PhoenixProgram;
import com.mmorrell.phoenix.program.PhoenixSeatManagerProgram;
Expand Down Expand Up @@ -94,6 +95,8 @@ public void phoenixGetMarketDetailTest() throws RpcException, IOException {
log.info("Base lots per base unit: {}", baseLotsPerBaseUnit);
log.info("Tick size in quote lots per base unit: {}", tickSizeInQuoteLotsPerBaseUnit);

PhoenixMarket phoenixMarket = PhoenixMarket.readPhoenixMarket(data);
log.info("Phoenix market: {}", phoenixMarket.toString());
}

@Test
Expand Down

0 comments on commit e395937

Please sign in to comment.