@solard/cli 0.2.27 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solard/cli",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "description": "Command-line interface for the Solard SDK.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@solana/web3.js": "^1.98.4",
22
- "@solard/core": "0.2.27",
23
- "@solard/sdk": "0.2.27",
22
+ "@solard/core": "0.2.29",
23
+ "@solard/sdk": "0.2.29",
24
24
  "bs58": "^6.0.0",
25
25
  "measure-fn": "5.2.0"
26
26
  },
@@ -10,6 +10,7 @@ import {
10
10
  } from "@solard/core";
11
11
 
12
12
  import { resolveTradeTargets, type TradeTargets } from "./trade-targets.ts";
13
+ import { tradeFeeOptions } from "./trade-fees.ts";
13
14
  import { summarizeTradeRoute, type TradeRouteSummary } from "./trade-result.ts";
14
15
  import { parseVenuePreference, type TradeCommandFlags } from "./trade-venue.ts";
15
16
 
@@ -105,6 +106,7 @@ export async function runSmartBuyCommand({
105
106
  }
106
107
 
107
108
  const options = {
109
+ ...tradeFeeOptions(flags),
108
110
  slippageBps: intFlag(flags, "slippage-bps", 1_500),
109
111
  via: (flags.get("sender") ?? "rpc") as SenderId,
110
112
  skipSimulation: flags.has("skip-simulation"),
@@ -118,15 +120,22 @@ export async function runSmartBuyCommand({
118
120
  ? [
119
121
  await slrd
120
122
  .tx(target.refs[0]!)
123
+ .priorityFee(options.priorityFee)
121
124
  .buy(resolution.token!.mint, amount, options)
122
125
  .build(),
123
126
  ]
124
127
  : await slrd
125
128
  .composeMany(target.refs)
129
+ .priorityFee(options.priorityFee)
126
130
  .buy(resolution.token!.mint, amount, options)
127
131
  .build();
128
132
  const results = await Promise.all(
129
- plans.map((plan) => slrd.simulatePlan(plan)),
133
+ plans.map(async (plan, index) => {
134
+ const prepared = await slrd.prepareTradePlan(target.refs[index]!, plan, options);
135
+ return { ...await slrd.simulatePlan(prepared.plan),
136
+ priorityMicroLamports: prepared.priorityMicroLamports,
137
+ cuLimit: prepared.plan.draft.cuLimit ?? 600_000 };
138
+ }),
130
139
  );
131
140
  return {
132
141
  mode: "simulation",
@@ -9,6 +9,7 @@ import {
9
9
  } from "@solard/core";
10
10
 
11
11
  import { resolveTradeTargets, type TradeTargets } from "./trade-targets.ts";
12
+ import { tradeFeeOptions } from "./trade-fees.ts";
12
13
  import { summarizeTradeRoute, type TradeRouteSummary } from "./trade-result.ts";
13
14
  import { parseVenuePreference, type TradeCommandFlags } from "./trade-venue.ts";
14
15
 
@@ -142,6 +143,7 @@ export async function runSmartSellCommand({
142
143
  }
143
144
 
144
145
  const options = {
146
+ ...tradeFeeOptions(flags),
145
147
  bps,
146
148
  slippageBps: intFlag(flags, "slippage-bps", 1_500),
147
149
  via: (flags.get("sender") ?? "rpc") as SenderId,
@@ -156,15 +158,22 @@ export async function runSmartSellCommand({
156
158
  ? [
157
159
  await slrd
158
160
  .tx(target.refs[0]!)
161
+ .priorityFee(options.priorityFee)
159
162
  .sell(resolution.token!.mint, options)
160
163
  .build(),
161
164
  ]
162
165
  : await slrd
163
166
  .composeMany(target.refs)
167
+ .priorityFee(options.priorityFee)
164
168
  .sell(resolution.token!.mint, options)
165
169
  .build();
166
170
  const results = await Promise.all(
167
- plans.map((plan) => slrd.simulatePlan(plan)),
171
+ plans.map(async (plan, index) => {
172
+ const prepared = await slrd.prepareTradePlan(target.refs[index]!, plan, options);
173
+ return { ...await slrd.simulatePlan(prepared.plan),
174
+ priorityMicroLamports: prepared.priorityMicroLamports,
175
+ cuLimit: prepared.plan.draft.cuLimit ?? 600_000 };
176
+ }),
168
177
  );
169
178
  return {
170
179
  mode: "simulation",
@@ -0,0 +1,15 @@
1
+ import { expect, test } from "bun:test";
2
+ import { tradeFeeOptions } from "./trade-fees.ts";
3
+
4
+ test("native buy/sell fee flags preserve custom compute limit and price", () => {
5
+ expect(tradeFeeOptions(new Map([
6
+ ["cu-limit", "150000"], ["priority-micro-lamports", "1000000"],
7
+ ["trade-attempts", "4"], ["max-priority-fee-lamports", "500000"],
8
+ ]))).toMatchObject({ priorityFee: { cuLimit: 150_000, microLamports: 1_000_000 },
9
+ landing: { maxAttempts: 4, maxPriorityFeeLamports: 500_000 } });
10
+ });
11
+
12
+ test("invalid fee flags reject instead of being ignored", () => {
13
+ for (const [name, value] of [["cu-limit", "0"], ["priority-micro-lamports", "-1"], ["priority-micro-lamports", "true"]])
14
+ expect(() => tradeFeeOptions(new Map([[name!, value!]]))).toThrow();
15
+ });
@@ -0,0 +1,24 @@
1
+ import type { TradeLandingPolicy } from "@solard/core";
2
+
3
+ /** Validate fee flags before constructing or signing a trade. */
4
+ export function tradeFeeOptions(flags: ReadonlyMap<string, string>) {
5
+ const number = (name: string): number | undefined => {
6
+ if (!flags.has(name)) return undefined;
7
+ const value = Number(flags.get(name));
8
+ if (!Number.isFinite(value)) throw new Error(`--${name} must be a number`);
9
+ return value;
10
+ };
11
+ const cuLimit = number("cu-limit");
12
+ const microLamports = number("priority-micro-lamports");
13
+ if (cuLimit != null && (!Number.isInteger(cuLimit) || cuLimit < 1 || cuLimit > 1_400_000))
14
+ throw new Error("--cu-limit must be an integer between 1 and 1400000");
15
+ if (microLamports != null && (!Number.isSafeInteger(microLamports) || microLamports < 0))
16
+ throw new Error("--priority-micro-lamports must be a non-negative integer");
17
+ const landing: TradeLandingPolicy = {
18
+ maxAttempts: number("trade-attempts"),
19
+ feeMultiplier: number("fee-multiplier"),
20
+ feePercentile: number("fee-percentile"),
21
+ maxPriorityFeeLamports: number("max-priority-fee-lamports"),
22
+ };
23
+ return { priorityFee: { cuLimit, microLamports }, landing };
24
+ }
package/src/index.ts CHANGED
@@ -446,6 +446,7 @@ Trading
446
446
  slrd buy <future-mint> (--wallet <wallet> | --group <name>) (--sol <amount> | --lamports <amount> | --min-bps <n> --max-bps <n>) --spam [--live]
447
447
  slrd spam-buy [pump] <future-mint> (--wallet <wallet> | --group <name>) (--sol <amount> | --lamports <amount> | --min-bps <n> --max-bps <n>) [--sender <id>] [--live]
448
448
  slrd sell <token|ca> (--wallet <wallet> | --wallets <w1,w2> | --group <name>) [--bps 10000] [--venue auto|native|jupiter] [--slippage-bps 1500] [--sender rpc|helius|jito] [--simulate-only]
449
+ Native buy/sell fees: --cu-limit N --priority-micro-lamports N (fixed), or --fee-percentile N --trade-attempts N --fee-multiplier N --max-priority-fee-lamports N (automatic)
449
450
  slrd unwrap-wsol (--all-wallets | --wallet <wallet> | --wallets <w1,w2> | --group <name>) [--sender rpc|helius|jito] [--ignore-missing] [--simulate-only]
450
451
  Close every owned WSOL token account, including non-ATA WSOL accounts
451
452
  slrd reclaim inspect --all-wallets List Loader-v3 buffers/programs controlled by stored wallets