Skip to content

Lightprotocol/example-jupiter-swap-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jup Swap with Compressed Tokens - Demo

This is an example using @lightprotocol/jup-api-adapter - a thin wrapper for the Jupiter API with compressed token support.

For details, see jup-api-adapter.

Setup

  1. Create .env from .env.example
  2. Fund FILE_WALLET at SWAP_USER_KEYPAIR_PATH with small amount of INPUT_MINT.

Usage

yarn # install deps
yarn quote          # get quote
yarn swap           # quote + send tx
  • src/swap-with-transaction.ts requests the tx from the Jup API via swapPostCompressed.
  • src/swap-with-instructions.ts requests the ixs via swapInstructionsPostCompressed and builds the tx manually.
yarn quote-ixs      # get quote
yarn swap-ixs       # quote + send tx

Notes

  • This e2e integration does not require on-chain changes to the Jup program.
  • Demo requires directSwapsOnly=true to avoid occasional tx size overruns (+ ~300 bytes overhead). This can be fixed by integrating natively in Jup's API for setupInstructions and cleanupInstructions.
  • Future/Optional: useSharedAccounts could remove the need for intermediate ATA setup and cleanup.

Example tx sigs:

with compressTokenOutIx:

without compressTokenOutIx:

To use the compressTokenOutIx feature, checkout this branch.

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published