Skip Jupiter Perps position increase when USDC balance is insufficient #41

Closed
opened 2026-07-25 12:57:35 +02:00 by minimons · 0 comments
Owner

Background

JupiterPerpsPositionIncreaseAlarmAction currently assumes that the configured wallet contains enough USDC for CollateralUSDC.

This may cause an unnecessary Jupiter transaction-build request when the transaction cannot succeed.

Implementation

Before calling buildPositionIncreaseTransaction(...), retrieve the wallet's USDC balance and compare it with the resolved collateralUsd.

If the balance is lower than the required collateral:

  • Log the available and required USDC amounts.
  • Return without requesting, signing, or submitting a transaction.
  • Allow the remaining alarm actions to continue normally.

Example log message:

Position Increase skipped: wallet has 1.25 USDC, but 2.50 USDC is required.

The balance check must use the SPL-token balance functionality added by the preceding issue.

Checking the SOL balance for transaction fees is out of scope.

Acceptance criteria

  • The USDC balance is checked after resolving the alarm definition.
  • The check occurs before requesting a transaction from Jupiter.
  • Insufficient balance prevents building, signing, and submitting the transaction.
  • The available and required amounts are logged.
  • Sufficient balance preserves the existing Increase flow.
  • Other alarm actions continue to run.
  • The project compiles successfully.
## Background `JupiterPerpsPositionIncreaseAlarmAction` currently assumes that the configured wallet contains enough USDC for `CollateralUSDC`. This may cause an unnecessary Jupiter transaction-build request when the transaction cannot succeed. ## Implementation Before calling `buildPositionIncreaseTransaction(...)`, retrieve the wallet's USDC balance and compare it with the resolved `collateralUsd`. If the balance is lower than the required collateral: * Log the available and required USDC amounts. * Return without requesting, signing, or submitting a transaction. * Allow the remaining alarm actions to continue normally. Example log message: ```text Position Increase skipped: wallet has 1.25 USDC, but 2.50 USDC is required. ``` The balance check must use the SPL-token balance functionality added by the preceding issue. Checking the SOL balance for transaction fees is out of scope. ## Acceptance criteria * The USDC balance is checked after resolving the alarm definition. * The check occurs before requesting a transaction from Jupiter. * Insufficient balance prevents building, signing, and submitting the transaction. * The available and required amounts are logged. * Sufficient balance preserves the existing Increase flow. * Other alarm actions continue to run. * The project compiles successfully.
minimons added the enhancement label 2026-07-25 12:57:35 +02:00
minimons self-assigned this 2026-07-25 12:57:35 +02:00
minimons added this to the Evelyn project 2026-07-25 12:57:35 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: r35157/com_r35157_nenjim-hubd-impl_ref#41