Skip to content

Commit

Permalink
add compressTokenOutIx to readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Swenschaeferjohann authored and Swenschaeferjohann committed Nov 27, 2024
1 parent 3ab758e commit df93cab
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
## Jup Swap with Compressed Tokens - Demo

- Creates a single swap transaction with [additional instructions](https://github.com/Lightprotocol/example-jupiter-swap-node/blob/main/src/buildCompressedSwapTx.ts#L192-L200): `createInAtaIx`, `decompressIx`, `closeInAtaIx`
- Accepts compressed tokens as tokenIn.
- Cleans up ATA for tokenIn after swap.
- Clean up ATA for tokenOut via `compressOutAtaIx` support is in progress.
- Creates a single swap transaction with [additional instructions](https://github.com/Lightprotocol/example-jupiter-swap-node/blob/main/src/buildCompressedSwapTx.ts#L192-L200): `createTokenInAtaIx`, `createTokenOutAtaIx`, `decompressTokenInIx`, `compressTokenOutIx`, `closeTokenInAtaIx`, `closeTokenOutAtaIx`
- Accepts compressed tokens as tokenIn
- Returns compressed tokens as tokenOut
- Cleans up intermediate ATAs for tokenIn after the swap
- Cleans up ATA for tokenOut after the swap.

to use the `compressTokenOutIx` feature, checkout [this branch](https://github.com/Lightprotocol/example-jupiter-swap-node/tree/use-compress-out-ata).

### 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.

### Setup

Expand All @@ -23,18 +28,27 @@ yarn

```
# get quotes, see tx size
ROUNDS=5 yarn dryrun # runs 5 rounds
yarn dryrun # runs 1 round (default)
yarn quote # runs 1 round (default)
ROUNDS=5 yarn quote # runs 5 rounds
COMPRESS_TOKEN_OUT=true yarn quote # uses compressTokenOutIx feature (default: false)
```

```
# also send and confirm
ROUNDS=5 yarn send # runs 5 rounds
yarn send # runs 1 round (default)
yarn swap # runs 1 round (default)
ROUNDS=5 yarn swap # runs 5 rounds
COMPRESS_TOKEN_OUT=true yarn swap # uses compressTokenOutIx feature (default: false)
```

### Example tx sigs:

with compressTokenOutIx:

- https://solscan.io/tx/47duf8bTsK7Fi6dQgeHbD3GwPXC1GFiiBnLEq1i6jSRtKcwc2by7Rxbx7dxkKeA6EyVuJf1b5BhL6EKgsSAzFKXG
- https://solscan.io/tx/2qdBGCKhGnhSQKfoyiY3eHoChuHkQ7QtZpCR9m2CWTvLxwivxcRTNpUqtQkxPrWHd2ibh5QWwjsTjGnq7VsmAwzd

without compressTokenOutIx:

- https://solscan.io/tx/4QiVMPKYQxZTQZagT6LDaooaUecSzFNTWkHM3UsQ7om2WvzqLWip3GQ5Gj8a4pYBuLD124RVnP2QKvp6EPRBidTK
- https://solscan.io/tx/5JPv1k9HRqdzie8DcpYFFbwcLmdxYFu9rLpyrFFYii4AE6XPfrk59tgpRasZfykvLn6QgLhzBCKxFvBaNWTYRp4K
- https://solscan.io/tx/3KVwEPz1XFxNifz7hptqQWSeM3vgxBDCj2v1SwLMjgRS9iKLi8mEoHzyuvcsAzMjPwLp9c3mizUy5hKYSKXELwuV
Expand Down

0 comments on commit df93cab

Please sign in to comment.