23: Investigate and expose closeFeeUsd in JupiterPerpsPosition
This commit is contained in:
+18
-6
@@ -117,10 +117,9 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
ΩJupiterPostionInterestΩ positionInterest = custodyAccountInfo.currentCumulativeInterestRate()
|
ΩJupiterPostionInterestΩ positionInterest = custodyAccountInfo.currentCumulativeInterestRate()
|
||||||
.subtract(perpsPositionInfo.cumulativeInterestSnapshot());
|
.subtract(perpsPositionInfo.cumulativeInterestSnapshot());
|
||||||
|
|
||||||
ΩUSDCAmountΩ borrowFeesDue = calculateBorrowFeesDue(
|
ΩUSDCAmountΩ positionSize = perpsPositionInfo.positionSize();
|
||||||
positionInterest,
|
ΩUSDCAmountΩ borrowFeesDue = calculateBorrowFeesDue(positionInterest, positionSize);
|
||||||
perpsPositionInfo.positionSize()
|
ΩUSDCAmountΩ closeFeePending = calculateCloseFeePending(positionSize);
|
||||||
);
|
|
||||||
|
|
||||||
ΩUSDCAmountΩ value = ZERO; // TODO - Dummy
|
ΩUSDCAmountΩ value = ZERO; // TODO - Dummy
|
||||||
ΩUSDCAmountΩ pnl = ZERO; // TODO - Dummy
|
ΩUSDCAmountΩ pnl = ZERO; // TODO - Dummy
|
||||||
@@ -128,7 +127,6 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
BigDecimal leverage = ZERO; // TODO - Dummy
|
BigDecimal leverage = ZERO; // TODO - Dummy
|
||||||
ΩUSDCPriceΩ marketPrice = ZERO; // TODO - Dummy
|
ΩUSDCPriceΩ marketPrice = ZERO; // TODO - Dummy
|
||||||
ΩUSDCAmountΩ totalFees = ZERO; // TODO - Dummy
|
ΩUSDCAmountΩ totalFees = ZERO; // TODO - Dummy
|
||||||
ΩUSDCAmountΩ closeFeePending = ZERO; // TODO - Dummy
|
|
||||||
ΩSolanaAmountΩ accountRent = new MoneyAmount( // TODO - Dummy
|
ΩSolanaAmountΩ accountRent = new MoneyAmount( // TODO - Dummy
|
||||||
ZERO,
|
ZERO,
|
||||||
WellKnownCurrencyTypes.SOLANA.getCurrencyType()
|
WellKnownCurrencyTypes.SOLANA.getCurrencyType()
|
||||||
@@ -139,7 +137,7 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
mintAddress,
|
mintAddress,
|
||||||
perpsPositionInfo.direction(),
|
perpsPositionInfo.direction(),
|
||||||
value,
|
value,
|
||||||
perpsPositionInfo.positionSize(),
|
positionSize,
|
||||||
pnl,
|
pnl,
|
||||||
pnlPercent,
|
pnlPercent,
|
||||||
leverage,
|
leverage,
|
||||||
@@ -169,7 +167,21 @@ public class AnchorIdlJupiterPerpsServiceImpl implements JupiterPerpsService {
|
|||||||
return fees;
|
return fees;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ΩUSDCAmountΩ calculateCloseFeePending(ΩUSDCAmountΩ size) {
|
||||||
|
ΩUSDCAmountΩ fee = size
|
||||||
|
.multiply(BigDecimal.valueOf(CLOSE_FEE_BPS))
|
||||||
|
.divide(
|
||||||
|
BigDecimal.valueOf(BASIS_POINTS_DIVISOR),
|
||||||
|
6,
|
||||||
|
RoundingMode.CEILING
|
||||||
|
);
|
||||||
|
|
||||||
|
return fee;
|
||||||
|
}
|
||||||
|
|
||||||
private static final long RATE_POWER = 1_000_000_000L;
|
private static final long RATE_POWER = 1_000_000_000L;
|
||||||
|
private static final int CLOSE_FEE_BPS = 6;
|
||||||
|
private static final int BASIS_POINTS_DIVISOR = 10_000;
|
||||||
private static final ΩJupiterPerpsProgramIdΩ JUPITER_PERPS_PROGRAM_ID =
|
private static final ΩJupiterPerpsProgramIdΩ JUPITER_PERPS_PROGRAM_ID =
|
||||||
"PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu";
|
"PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu";
|
||||||
private static final int POSITION_OWNER_OFFSET = 8;
|
private static final int POSITION_OWNER_OFFSET = 8;
|
||||||
|
|||||||
Reference in New Issue
Block a user