Compare commits
1 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| 0931dbe99a |
+21
-3
@@ -1,9 +1,28 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <github-snapshot-branch>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BRANCH="$1"
|
||||||
|
|
||||||
SOURCE="$HOME/projects/com_r35157_nenjim-hubd-impl_ref"
|
SOURCE="$HOME/projects/com_r35157_nenjim-hubd-impl_ref"
|
||||||
TARGET="$HOME/projects/com_r35157_nenjim-hubd-impl_ref_github_snapshot"
|
TARGET="$HOME/projects/com_r35157_nenjim-hubd-impl_ref_github_snapshot"
|
||||||
|
|
||||||
|
cd "$TARGET"
|
||||||
|
|
||||||
|
git fetch origin
|
||||||
|
|
||||||
|
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
|
||||||
|
git switch "$BRANCH"
|
||||||
|
elif git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then
|
||||||
|
git switch --track "origin/$BRANCH"
|
||||||
|
else
|
||||||
|
git switch --create "$BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
rsync -a --delete \
|
rsync -a --delete \
|
||||||
--exclude '.git' \
|
--exclude '.git' \
|
||||||
--exclude 'conf/*.conf' \
|
--exclude 'conf/*.conf' \
|
||||||
@@ -11,13 +30,12 @@ rsync -a --delete \
|
|||||||
"$SOURCE/" \
|
"$SOURCE/" \
|
||||||
"$TARGET/"
|
"$TARGET/"
|
||||||
|
|
||||||
cd "$TARGET"
|
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "No snapshot changes to publish."
|
echo "No snapshot changes to publish on branch '$BRANCH'."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git commit -m "Mirror snapshot"
|
git commit -m "Mirror snapshot"
|
||||||
git push
|
git push -u origin "$BRANCH"
|
||||||
|
|||||||
+1
-39
@@ -7,7 +7,6 @@ import com.r35157.libs.jupiter.perps.JupiterPerpsPositionDirection;
|
|||||||
import com.r35157.libs.solana.SolanaAccountInfo;
|
import com.r35157.libs.solana.SolanaAccountInfo;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -57,11 +56,6 @@ class AnchorIdlJupiterPerpsPositionDecoder {
|
|||||||
.valueOf(rawSizeUsd)
|
.valueOf(rawSizeUsd)
|
||||||
.movePointLeft(6);
|
.movePointLeft(6);
|
||||||
|
|
||||||
BigInteger cumulativeInterestSnapshot = readU128(
|
|
||||||
data,
|
|
||||||
CUMULATIVE_INTEREST_SNAPSHOT_OFFSET
|
|
||||||
);
|
|
||||||
|
|
||||||
JupiterPerpsPosition pos = new JupiterPerpsPosition(
|
JupiterPerpsPosition pos = new JupiterPerpsPosition(
|
||||||
positionAccount,
|
positionAccount,
|
||||||
entryPrice,
|
entryPrice,
|
||||||
@@ -74,22 +68,6 @@ class AnchorIdlJupiterPerpsPositionDecoder {
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
BigInteger decodeCumulativeInterestSnapshot(SolanaAccountInfo accountInfo) {
|
|
||||||
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());
|
|
||||||
|
|
||||||
if (data.length < CUMULATIVE_INTEREST_SNAPSHOT_OFFSET + U128_LENGTH) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Jupiter Perps position account data is too short: " + data.length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
BigInteger value = readU128(
|
|
||||||
data,
|
|
||||||
CUMULATIVE_INTEREST_SNAPSHOT_OFFSET
|
|
||||||
);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ΩSolanaAddressΩ decodeCustodyAccount(SolanaAccountInfo accountInfo) {
|
ΩSolanaAddressΩ decodeCustodyAccount(SolanaAccountInfo accountInfo) {
|
||||||
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());
|
byte[] data = Base64.getDecoder().decode(accountInfo.dataBase64());
|
||||||
|
|
||||||
@@ -137,25 +115,11 @@ class AnchorIdlJupiterPerpsPositionDecoder {
|
|||||||
return base58.encode(publicKeyBytes);
|
return base58.encode(publicKeyBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BigInteger readU128(
|
|
||||||
byte[] data,
|
|
||||||
int offset
|
|
||||||
) {
|
|
||||||
byte[] bytes = new byte[U128_LENGTH];
|
|
||||||
|
|
||||||
for (int i = 0; i < U128_LENGTH; i++) {
|
|
||||||
bytes[i] = data[offset + U128_LENGTH - 1 - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BigInteger(1, bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ANCHOR_DISCRIMINATOR_LENGTH = 8;
|
private static final int ANCHOR_DISCRIMINATOR_LENGTH = 8;
|
||||||
private static final int PUBLIC_KEY_LENGTH = 32;
|
private static final int PUBLIC_KEY_LENGTH = 32;
|
||||||
private static final int SIDE_ENUM_LENGTH = 1;
|
|
||||||
private static final int I64_LENGTH = 8;
|
private static final int I64_LENGTH = 8;
|
||||||
|
private static final int SIDE_ENUM_LENGTH = 1;
|
||||||
private static final int U64_LENGTH = 8;
|
private static final int U64_LENGTH = 8;
|
||||||
private static final int U128_LENGTH = 16;
|
|
||||||
|
|
||||||
private static final int OWNER_OFFSET = ANCHOR_DISCRIMINATOR_LENGTH;
|
private static final int OWNER_OFFSET = ANCHOR_DISCRIMINATOR_LENGTH;
|
||||||
private static final int POOL_OFFSET = OWNER_OFFSET + PUBLIC_KEY_LENGTH;
|
private static final int POOL_OFFSET = OWNER_OFFSET + PUBLIC_KEY_LENGTH;
|
||||||
@@ -167,8 +131,6 @@ class AnchorIdlJupiterPerpsPositionDecoder {
|
|||||||
private static final int PRICE_OFFSET = SIDE_OFFSET + SIDE_ENUM_LENGTH;
|
private static final int PRICE_OFFSET = SIDE_OFFSET + SIDE_ENUM_LENGTH;
|
||||||
private static final int SIZE_USD_OFFSET = PRICE_OFFSET + U64_LENGTH;
|
private static final int SIZE_USD_OFFSET = PRICE_OFFSET + U64_LENGTH;
|
||||||
private static final int COLLATERAL_USD_OFFSET = SIZE_USD_OFFSET + U64_LENGTH;
|
private static final int COLLATERAL_USD_OFFSET = SIZE_USD_OFFSET + U64_LENGTH;
|
||||||
private static final int REALISED_PNL_USD_OFFSET = COLLATERAL_USD_OFFSET + U64_LENGTH;
|
|
||||||
private static final int CUMULATIVE_INTEREST_SNAPSHOT_OFFSET = REALISED_PNL_USD_OFFSET + I64_LENGTH;
|
|
||||||
|
|
||||||
private static final Base58Codec base58 = new Base58CodecImpl();
|
private static final Base58Codec base58 = new Base58CodecImpl();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user