Skip to content

Lightprotocol/example-jupiter-swap-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jup Swap with Compressed Tokens - Demo

  • Creates a single swap transaction with additional instructions: createInAtaIx, decompressIx, closeInAtaIx
  • Accepts compressed tokens as tokenIn.
  • Cleans up ATA for tokenIn after swap.
  • Does not clean up nor compress tokenOut. (Enable this via CPI)

Notes

  • Demo requires directSwapsOnly=true to avoid occasional tx size overrun (+ ~300 bytes overhead). This can be fixed by integrating natively in Jup's API for setupInstructions and cleanupInstructions.

  • Further optimization paths:

    • Add compressTokenOut option. Requires invocation via CPI to get exactOut.
    • Enable use of sharedTokenAccounts to avoid opening and closing ATAs for tokenIn/tokenOut.

Setup

  1. Create .env from .env.example
  2. Fund FILE_WALLET at SWAP_USER_KEYPAIR_PATH with small amount of INPUT_MINT.
  3. May require large slippage/priority fee to land. you can change configs in src/constants.ts.

Run

yarn
# get quotes, see tx size
ROUNDS=5 yarn dryrun    # runs 5 rounds
yarn dryrun            # runs 1 round (default)
# also send and confirm
ROUNDS=5 yarn send      # runs 5 rounds
yarn send              # runs 1 round (default)

Example tx sigs:

No safeguards. Use at your own risk. Set small amounts. ensure your INPUT_MINT tokenBalances are small.