13: Inject dependencies and fetch info for given position account
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.r35157.libs.jupiter.perps;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface JupiterPerpsPositionService {
|
||||
JupiterPerpsPosition getPosition(ΩJupiterPerpsPositionAccountΩ positionAccount);
|
||||
JupiterPerpsPosition getPosition(ΩJupiterPerpsPositionAccountΩ positionAccount)
|
||||
throws IOException, InterruptedException;
|
||||
}
|
||||
+27
-2
@@ -2,11 +2,36 @@ package com.r35157.libs.jupiter.perps.impl.anchoridl;
|
||||
|
||||
import com.r35157.libs.jupiter.perps.JupiterPerpsPosition;
|
||||
import com.r35157.libs.jupiter.perps.JupiterPerpsPositionService;
|
||||
import com.r35157.libs.solana.SolanaAccountInfo;
|
||||
import com.r35157.libs.solana.SolanaBlockChain;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AnchorIdlJupiterPerpsPositionServiceImpl implements JupiterPerpsPositionService {
|
||||
|
||||
private final SolanaBlockChain solanaBlockChain;
|
||||
|
||||
public AnchorIdlJupiterPerpsPositionServiceImpl(
|
||||
SolanaBlockChain solanaBlockChain
|
||||
) {
|
||||
this.solanaBlockChain = solanaBlockChain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JupiterPerpsPosition getPosition(ΩJupiterPerpsPositionAccountΩ positionAccount) {
|
||||
throw new UnsupportedOperationException("Reading Jupiter Perps positions is not implemented yet.");
|
||||
public JupiterPerpsPosition getPosition(
|
||||
ΩJupiterPerpsPositionAccountΩ positionAccount
|
||||
) throws IOException, InterruptedException {
|
||||
SolanaAccountInfo accountInfo =
|
||||
solanaBlockChain.getAccountInfo(positionAccount);
|
||||
|
||||
if (accountInfo == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Jupiter Perps position account does not exist: " + positionAccount
|
||||
);
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException(
|
||||
"Jupiter Perps position account decoding is not implemented yet."
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user