@solard/sdk 0.2.13 → 0.2.15

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/sdk",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Public Solard SDK for wallets, transactions, trading and token launches.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -22,7 +22,7 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "@solana/web3.js": "^1.98.4",
25
- "@solard/core": "0.2.13"
25
+ "@solard/core": "0.2.15"
26
26
  },
27
27
  "scripts": {
28
28
  "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json",
@@ -6,11 +6,32 @@ import {
6
6
  VersionedTransaction,
7
7
  } from "@solana/web3.js";
8
8
 
9
+ import {
10
+ buildPumpExternalDeployment,
11
+ type PumpLaunchPairInput,
12
+ } from "@solard/core/launches/pump/external-deployment.ts";
13
+
14
+ import {
15
+ snapshotTokenHolders,
16
+ type TokenHolderSnapshotOptions,
17
+ } from "@solard/core/chain/holders.ts";
18
+ import { readMint } from "@solard/core/chain/state.ts";
19
+ import {
20
+ subscribeTokenEvents,
21
+ type SubscribeTokenEventsOptions,
22
+ } from "@solard/core/events/token-events.ts";
23
+ import type { TokenRow } from "@solard/core/db/schema.ts";
24
+ import { PumpCurveVenue } from "@solard/core/venues/pump/pump-curve-venue.ts";
25
+ import { PumpSwapVenue } from "@solard/core/venues/pump/pumpswap-venue.ts";
26
+ import { VenueRegistry } from "@solard/core/venues/route-resolver.ts";
27
+
9
28
  import { BrowserSolardStore, defaultBrowserStorage } from "./storage.ts";
10
29
  import { buildLocalPumpBuy, buildLocalPumpSell } from "./pump.ts";
11
30
  import type {
12
31
  BrowserBroadcastResult,
13
32
  BrowserPortfolio,
33
+ BrowserPumpDeploymentBuild,
34
+ BrowserPumpDeploymentResult,
14
35
  BrowserSolardOptions,
15
36
  BrowserTradeBuild,
16
37
  BrowserTradeResult,
@@ -170,6 +191,67 @@ export class BrowserSolard {
170
191
  }
171
192
  }
172
193
 
194
+ private async inspectPumpToken(value: string): Promise<TokenRow> {
195
+ const mintText = this.resolveTokenOrMint(value);
196
+ const mint = new PublicKey(mintText);
197
+ const info = await readMint(this.connection, mint);
198
+ const registry = new VenueRegistry()
199
+ .register(new PumpCurveVenue())
200
+ .register(new PumpSwapVenue());
201
+ const inspected = await registry.inspect(this.connection, mint);
202
+ if (!inspected)
203
+ throw new Error(
204
+ `Mint ${mintText} is not a supported Pump/PumpSwap token.`,
205
+ );
206
+ const now = Date.now();
207
+ return {
208
+ id: 0,
209
+ mint: mintText,
210
+ name: null,
211
+ symbol: null,
212
+ decimals: info.decimals,
213
+ createKind: "unknown",
214
+ creator: null,
215
+ quoteMint: null,
216
+ quoteTokenProgram: null,
217
+ baseTokenProgram: info.tokenProgram.toBase58(),
218
+ bondingCurve: null,
219
+ pool: null,
220
+ sharingConfig: null,
221
+ venueHint: "unknown",
222
+ metadataJson: null,
223
+ refreshedAtMs: now,
224
+ createdAtMs: now,
225
+ updatedAtMs: now,
226
+ ...inspected,
227
+ } as TokenRow;
228
+ }
229
+
230
+ /** Complete holder snapshot suitable for reward allocation. */
231
+ async snapshotHolders(
232
+ token: string,
233
+ options: Omit<TokenHolderSnapshotOptions, "token"> = {},
234
+ ) {
235
+ const row = await this.inspectPumpToken(token);
236
+ return await snapshotTokenHolders(this.connection, row.mint, {
237
+ ...options,
238
+ token: row,
239
+ });
240
+ }
241
+
242
+ /** Typed Pump/PumpSwap swap and mint-mentioned transfer stream. */
243
+ async subscribeTokenEvents(
244
+ token: string,
245
+ options: SubscribeTokenEventsOptions = {},
246
+ ) {
247
+ const row = await this.inspectPumpToken(token);
248
+ return await subscribeTokenEvents({
249
+ connection: this.connection,
250
+ token: row,
251
+ options,
252
+ });
253
+ }
254
+
173
255
  async getPortfolio(address?: string | PublicKey): Promise<BrowserPortfolio> {
174
256
  const owner =
175
257
  address instanceof PublicKey
@@ -316,6 +398,59 @@ export class BrowserSolard {
316
398
  );
317
399
  }
318
400
 
401
+ /**
402
+ * Build a Pump create_v2 transaction for the connected wallet without asking
403
+ * it to sign and without broadcasting. The generated mint signature is already
404
+ * present; the connected wallet remains the missing payer signature.
405
+ */
406
+ async buildPumpDeployment(args: {
407
+ name: string;
408
+ symbol: string;
409
+ uri: string;
410
+ pair?: PumpLaunchPairInput;
411
+ beneficiary?: string | PublicKey;
412
+ mayhemMode?: boolean;
413
+ cashback?: boolean;
414
+ cuLimit?: number;
415
+ priorityMicroLamports?: number;
416
+ }): Promise<BrowserPumpDeploymentBuild> {
417
+ const payer = this.signer().publicKey;
418
+ if (!payer) throw new Error("Connected browser wallet has no public key.");
419
+ return await buildPumpExternalDeployment({
420
+ connection: this.connection,
421
+ payer,
422
+ ...args,
423
+ });
424
+ }
425
+
426
+ /** Build, request the wallet signature, broadcast, and confirm a Pump launch. */
427
+ async deployPump(args: {
428
+ name: string;
429
+ symbol: string;
430
+ uri: string;
431
+ pair?: PumpLaunchPairInput;
432
+ beneficiary?: string | PublicKey;
433
+ mayhemMode?: boolean;
434
+ cashback?: boolean;
435
+ cuLimit?: number;
436
+ priorityMicroLamports?: number;
437
+ skipPreflight?: boolean;
438
+ }): Promise<BrowserPumpDeploymentResult> {
439
+ const build = await this.buildPumpDeployment(args);
440
+ const receipt = await this.signAndBroadcast(build.transaction, {
441
+ blockhash: build.blockhash,
442
+ lastValidBlockHeight: build.lastValidBlockHeight,
443
+ skipPreflight: args.skipPreflight,
444
+ });
445
+ return {
446
+ ...receipt,
447
+ mint: build.mint,
448
+ beneficiary: build.beneficiary,
449
+ quoteMint: build.quoteMint,
450
+ quoteKind: build.quoteKind,
451
+ };
452
+ }
453
+
319
454
  async buildBuy(args: {
320
455
  token: string;
321
456
  sol: string | number;
@@ -20,11 +20,38 @@ export {
20
20
  } from "./storage.ts";
21
21
  export { BrowserKeyVault, KeypairBrowserSigner } from "./wallet.ts";
22
22
  export { buildLocalPumpBuy, buildLocalPumpSell } from "./pump.ts";
23
+ export {
24
+ PUMP_USDC_MINT,
25
+ buildPumpExternalDeployment,
26
+ resolvePumpQuoteAsset,
27
+ } from "@solard/core/launches/pump/external-deployment.ts";
28
+ export type {
29
+ PumpExternalDeploymentBuild,
30
+ PumpCustomPairSelection,
31
+ PumpLaunchPairInput,
32
+ } from "@solard/core/launches/pump/external-deployment.ts";
33
+ export { snapshotTokenHolders } from "@solard/core/chain/holders.ts";
34
+ export type {
35
+ TokenHolder,
36
+ ExcludedTokenHolder,
37
+ TokenHolderSnapshot,
38
+ TokenHolderSnapshotOptions,
39
+ } from "@solard/core/chain/holders.ts";
40
+ export { subscribeTokenEvents } from "@solard/core/events/token-events.ts";
41
+ export type {
42
+ SolardTokenEvent,
43
+ SolardTokenSwapEvent,
44
+ SolardTokenTransferEvent,
45
+ SubscribeTokenEventsOptions,
46
+ TokenEventSubscription,
47
+ } from "@solard/core/events/token-events.ts";
23
48
 
24
49
  export type {
25
50
  BrowserBroadcastResult,
26
51
  BrowserContact,
27
52
  BrowserPortfolio,
53
+ BrowserPumpDeploymentBuild,
54
+ BrowserPumpDeploymentResult,
28
55
  BrowserSolardOptions,
29
56
  BrowserStorageLike,
30
57
  BrowserTokenAlias,
@@ -97,3 +97,12 @@ export type BrowserSolardOptions = {
97
97
  rpcMaxRps?: number;
98
98
  fetch?: typeof globalThis.fetch;
99
99
  };
100
+ export type BrowserPumpDeploymentBuild =
101
+ import("@solard/core/launches/pump/external-deployment.ts").PumpExternalDeploymentBuild;
102
+
103
+ export type BrowserPumpDeploymentResult = BrowserBroadcastResult & {
104
+ mint: string;
105
+ beneficiary: string;
106
+ quoteMint: string;
107
+ quoteKind: "native-sol" | "spl-token";
108
+ };
package/src/index.ts CHANGED
@@ -24,3 +24,30 @@ export type {
24
24
  // Direct source re-exports used by the source-executed CLI.
25
25
  export { readMint } from "../../core/src/chain/state.ts";
26
26
  export { transferTokenIxs } from "../../core/src/tx/spl.ts";
27
+ // Direct source re-exports for the target-weight portfolio controller and
28
+ // backtester. Keeping these explicit lets the source-executed CLI/examples use
29
+ // the new strategy without requiring a root @solard/core barrel replacement.
30
+ export {
31
+ normalizeTargetWeightPolicy,
32
+ planTargetWeightRebalance,
33
+ targetWeightGapPct,
34
+ } from "../../core/src/strategy/target-weight.ts";
35
+ export type {
36
+ TargetWeightCandle,
37
+ TargetWeightGapMode,
38
+ TargetWeightGapPolicy,
39
+ TargetWeightPolicy,
40
+ TargetWeightRebalancePlan,
41
+ } from "../../core/src/strategy/target-weight.ts";
42
+ export { simulateTargetWeightStrategy } from "../../core/src/backtest/target-weight-sim.ts";
43
+ export type {
44
+ TargetWeightBacktestExecution,
45
+ TargetWeightBacktestResult,
46
+ TargetWeightBacktestSummary,
47
+ TargetWeightDecision,
48
+ } from "../../core/src/backtest/target-weight-sim.ts";
49
+ export {
50
+ backtestTargetWeightToken,
51
+ backtestTargetWeightTokenWithDependencies,
52
+ } from "../../core/src/backtest/token-backtest.ts";
53
+ export type { TokenTargetWeightBacktestResult } from "../../core/src/backtest/token-backtest.ts";