Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/spot.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ jup spot quote --from <mint> --to <mint> --raw-amount 1000000000
```bash
jup spot swap --from SOL --to USDC --amount 1
jup spot swap --from SOL --to USDC --amount 1 --key mykey
jup spot swap --from SOL --to USDC --amount 1 --slippage 100
```

- `--slippage <bps>` max slippage in basis points (default: 30 = 0.3%)
- `--key` overrides the active key for this transaction

```js
Expand Down
1 change: 1 addition & 0 deletions src/clients/UltraClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type GetOrderRequest = {
outputMint: string;
amount: string;
taker?: string | undefined;
slippageBps?: number | undefined;
};

export type GetOrderResponse = {
Expand Down
8 changes: 8 additions & 0 deletions src/commands/SpotCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class SpotCommand {
"--raw-amount <n>",
"Amount in on-chain units (no decimal conversion)"
)
.option("--slippage <bps>", "Max slippage in basis points", "30")
.option("--key <name>", "Key to use for signing")
.action((opts) => this.swap(opts));
spot
Expand Down Expand Up @@ -200,10 +201,16 @@ export class SpotCommand {
to: string;
amount?: string;
rawAmount?: string;
slippage?: string;
key?: string;
}): Promise<void> {
this.validateAmountOpts(opts);

const slippageBps = Number(opts.slippage ?? "30");
if (isNaN(slippageBps) || slippageBps < 0 || slippageBps > 10000) {
throw new Error("--slippage must be 0-10000 (basis points)");
}

const settings = Config.load();
const [signer, inputToken, outputToken] = await Promise.all([
Signer.load(opts.key ?? settings.activeKey),
Expand All @@ -224,6 +231,7 @@ export class SpotCommand {
inputMultiplier
),
taker: signer.address,
slippageBps,
});

if (order.error) {
Expand Down