-
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.
- Loading branch information
Showing
5 changed files
with
89 additions
and
19 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
49 changes: 49 additions & 0 deletions
49
openbook/src/main/java/com/mmorrell/openbook/model/OpenBookFillEvent.java
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,49 @@ | ||
package com.mmorrell.openbook.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import org.p2p.solanaj.core.PublicKey; | ||
import org.p2p.solanaj.utils.ByteUtils; | ||
|
||
@Data | ||
@Builder | ||
public class OpenBookFillEvent { | ||
|
||
private byte eventType; | ||
private byte takerSide; | ||
private byte makerOut; | ||
private byte makerSlot; | ||
|
||
// 4 bytes padding | ||
private long timeStamp; | ||
private long seqNum; | ||
private PublicKey maker; | ||
private long makerTimeStamp; | ||
private PublicKey taker; | ||
private long takerClientOrderId; | ||
private long price; | ||
private long pegLimit; | ||
private long quantity; | ||
private long makerClientOrderId; | ||
// 8 bytes reserved padding | ||
|
||
public static OpenBookFillEvent readOpenBookFillEvent(byte[] data) { | ||
return OpenBookFillEvent.builder() | ||
.eventType((byte) 0) | ||
.takerSide(data[1]) | ||
.makerOut(data[2]) | ||
.makerSlot(data[3]) | ||
.timeStamp(ByteUtils.readUint64(data, 8).longValue()) | ||
.seqNum(ByteUtils.readUint64(data, 16).longValue()) | ||
.maker(PublicKey.readPubkey(data, 24)) | ||
.makerTimeStamp(ByteUtils.readUint64(data, 56).longValue()) | ||
.taker(PublicKey.readPubkey(data, 64)) | ||
.takerClientOrderId(ByteUtils.readUint64(data, 96).longValue()) | ||
.price(ByteUtils.readUint64(data, 104).longValue()) | ||
.pegLimit(ByteUtils.readUint64(data, 112).longValue()) | ||
.quantity(ByteUtils.readUint64(data, 120).longValue()) | ||
.makerClientOrderId(ByteUtils.readUint64(data, 128).longValue()) | ||
.build(); | ||
} | ||
|
||
} |
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