@solard/sdk 0.2.15 → 0.2.17
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 +2 -2
- package/src/browser/client.ts +60 -27
- package/src/browser/index.ts +13 -7
- package/src/browser/pump.ts +6 -6
- package/src/browser/types.ts +9 -6
- package/src/client.ts +141 -0
- package/src/export-surface.test.ts +101 -0
- package/src/index.ts +47 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solard/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
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.
|
|
25
|
+
"@solard/core": "0.2.17"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json",
|
package/src/browser/client.ts
CHANGED
|
@@ -9,26 +9,29 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
buildPumpExternalDeployment,
|
|
11
11
|
type PumpLaunchPairInput,
|
|
12
|
-
} from "@solard/core
|
|
12
|
+
} from "@solard/core";
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
snapshotTokenHolders,
|
|
16
16
|
type TokenHolderSnapshotOptions,
|
|
17
|
-
} from "@solard/core
|
|
18
|
-
import { readMint } from "@solard/core
|
|
17
|
+
} from "@solard/core";
|
|
18
|
+
import { readMint } from "@solard/core";
|
|
19
19
|
import {
|
|
20
20
|
subscribeTokenEvents,
|
|
21
21
|
type SubscribeTokenEventsOptions,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
22
|
+
type TokenEventSubscription,
|
|
23
|
+
} from "@solard/core";
|
|
24
|
+
import type { TokenRow } from "@solard/core";
|
|
25
|
+
import { PumpCurveVenue } from "@solard/core";
|
|
26
|
+
import { PumpSwapVenue } from "@solard/core";
|
|
27
|
+
import { VenueRegistry } from "@solard/core";
|
|
28
|
+
import { PumpPairService } from "@solard/core";
|
|
27
29
|
|
|
28
30
|
import { BrowserSolardStore, defaultBrowserStorage } from "./storage.ts";
|
|
29
31
|
import { buildLocalPumpBuy, buildLocalPumpSell } from "./pump.ts";
|
|
30
32
|
import type {
|
|
31
|
-
|
|
33
|
+
BrowserConfirmedTransaction,
|
|
34
|
+
BrowserTransactionSubmission,
|
|
32
35
|
BrowserPortfolio,
|
|
33
36
|
BrowserPumpDeploymentBuild,
|
|
34
37
|
BrowserPumpDeploymentResult,
|
|
@@ -43,7 +46,7 @@ export const SOL_MINT = "So11111111111111111111111111111111111111112";
|
|
|
43
46
|
export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
44
47
|
export const TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
45
48
|
export const TOKEN_2022_PROGRAM_ID =
|
|
46
|
-
"
|
|
49
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
47
50
|
|
|
48
51
|
const CANONICAL_LABELS: Record<string, string> = {
|
|
49
52
|
[SOL_MINT]: "WSOL",
|
|
@@ -114,6 +117,13 @@ export class BrowserSolard {
|
|
|
114
117
|
readonly store: BrowserSolardStore;
|
|
115
118
|
readonly contacts;
|
|
116
119
|
readonly tokens;
|
|
120
|
+
readonly pump: PumpPairService;
|
|
121
|
+
readonly events: {
|
|
122
|
+
subscribeToken: (
|
|
123
|
+
token: string,
|
|
124
|
+
options?: SubscribeTokenEventsOptions,
|
|
125
|
+
) => Promise<TokenEventSubscription>;
|
|
126
|
+
};
|
|
117
127
|
private wallet: BrowserWalletSigner | null;
|
|
118
128
|
|
|
119
129
|
constructor(readonly options: BrowserSolardOptions) {
|
|
@@ -127,6 +137,11 @@ export class BrowserSolard {
|
|
|
127
137
|
fetch: rpcFetch,
|
|
128
138
|
});
|
|
129
139
|
this.wallet = options.wallet ?? null;
|
|
140
|
+
this.pump = new PumpPairService(() => this.connection);
|
|
141
|
+
this.events = {
|
|
142
|
+
subscribeToken: (token, eventOptions = {}) =>
|
|
143
|
+
this.subscribeTokenEvents(token, eventOptions),
|
|
144
|
+
};
|
|
130
145
|
this.store = new BrowserSolardStore(
|
|
131
146
|
options.storage ?? defaultBrowserStorage(),
|
|
132
147
|
options.storageNamespace ?? "solard:browser:v1",
|
|
@@ -330,14 +345,14 @@ export class BrowserSolard {
|
|
|
330
345
|
};
|
|
331
346
|
}
|
|
332
347
|
|
|
333
|
-
async
|
|
348
|
+
async submitTransaction(
|
|
334
349
|
transaction: VersionedTransaction,
|
|
335
350
|
strategy: {
|
|
336
351
|
blockhash: string;
|
|
337
352
|
lastValidBlockHeight: number;
|
|
338
353
|
skipPreflight?: boolean;
|
|
339
354
|
},
|
|
340
|
-
): Promise<
|
|
355
|
+
): Promise<BrowserTransactionSubmission> {
|
|
341
356
|
const signed = await this.signer().signTransaction(transaction);
|
|
342
357
|
if (!(signed instanceof VersionedTransaction))
|
|
343
358
|
throw new Error("Browser wallet did not return a VersionedTransaction.");
|
|
@@ -349,30 +364,48 @@ export class BrowserSolard {
|
|
|
349
364
|
maxRetries: 0,
|
|
350
365
|
},
|
|
351
366
|
);
|
|
367
|
+
return {
|
|
368
|
+
signature,
|
|
369
|
+
blockhash: strategy.blockhash,
|
|
370
|
+
lastValidBlockHeight: strategy.lastValidBlockHeight,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
async confirmSubmission(
|
|
375
|
+
submission: BrowserTransactionSubmission,
|
|
376
|
+
): Promise<BrowserConfirmedTransaction> {
|
|
352
377
|
const confirmation = await this.connection.confirmTransaction(
|
|
353
378
|
{
|
|
354
|
-
signature,
|
|
355
|
-
blockhash:
|
|
356
|
-
lastValidBlockHeight:
|
|
379
|
+
signature: submission.signature,
|
|
380
|
+
blockhash: submission.blockhash,
|
|
381
|
+
lastValidBlockHeight: submission.lastValidBlockHeight,
|
|
357
382
|
},
|
|
358
383
|
"confirmed",
|
|
359
384
|
);
|
|
360
385
|
if (confirmation.value.err)
|
|
361
386
|
throw new Error(
|
|
362
|
-
`Transaction ${signature} failed: ${JSON.stringify(confirmation.value.err)}`,
|
|
387
|
+
`Transaction ${submission.signature} failed: ${JSON.stringify(confirmation.value.err)}`,
|
|
363
388
|
);
|
|
364
|
-
return {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
389
|
+
return { ...submission, status: "confirmed" };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
private async submitAndConfirm(
|
|
393
|
+
transaction: VersionedTransaction,
|
|
394
|
+
strategy: {
|
|
395
|
+
blockhash: string;
|
|
396
|
+
lastValidBlockHeight: number;
|
|
397
|
+
skipPreflight?: boolean;
|
|
398
|
+
},
|
|
399
|
+
): Promise<BrowserConfirmedTransaction> {
|
|
400
|
+
return await this.confirmSubmission(
|
|
401
|
+
await this.submitTransaction(transaction, strategy),
|
|
402
|
+
);
|
|
370
403
|
}
|
|
371
404
|
|
|
372
405
|
async sendSol(
|
|
373
406
|
destinationRef: string,
|
|
374
407
|
amountSol: string | number,
|
|
375
|
-
): Promise<
|
|
408
|
+
): Promise<BrowserConfirmedTransaction> {
|
|
376
409
|
const wallet = this.signer();
|
|
377
410
|
const destination = new PublicKey(
|
|
378
411
|
this.store.resolveDestination(destinationRef),
|
|
@@ -392,7 +425,7 @@ export class BrowserSolard {
|
|
|
392
425
|
}),
|
|
393
426
|
],
|
|
394
427
|
}).compileToV0Message();
|
|
395
|
-
return await this.
|
|
428
|
+
return await this.submitAndConfirm(
|
|
396
429
|
new VersionedTransaction(message),
|
|
397
430
|
latest,
|
|
398
431
|
);
|
|
@@ -437,7 +470,7 @@ export class BrowserSolard {
|
|
|
437
470
|
skipPreflight?: boolean;
|
|
438
471
|
}): Promise<BrowserPumpDeploymentResult> {
|
|
439
472
|
const build = await this.buildPumpDeployment(args);
|
|
440
|
-
const receipt = await this.
|
|
473
|
+
const receipt = await this.submitAndConfirm(build.transaction, {
|
|
441
474
|
blockhash: build.blockhash,
|
|
442
475
|
lastValidBlockHeight: build.lastValidBlockHeight,
|
|
443
476
|
skipPreflight: args.skipPreflight,
|
|
@@ -497,7 +530,7 @@ export class BrowserSolard {
|
|
|
497
530
|
skipPreflight?: boolean;
|
|
498
531
|
}): Promise<BrowserTradeResult> {
|
|
499
532
|
const build = await this.buildBuy(args);
|
|
500
|
-
const receipt = await this.
|
|
533
|
+
const receipt = await this.submitAndConfirm(build.transaction, {
|
|
501
534
|
blockhash: build.blockhash,
|
|
502
535
|
lastValidBlockHeight: build.lastValidBlockHeight,
|
|
503
536
|
skipPreflight: args.skipPreflight,
|
|
@@ -522,7 +555,7 @@ export class BrowserSolard {
|
|
|
522
555
|
skipPreflight?: boolean;
|
|
523
556
|
}): Promise<BrowserTradeResult> {
|
|
524
557
|
const build = await this.buildSell(args);
|
|
525
|
-
const receipt = await this.
|
|
558
|
+
const receipt = await this.submitAndConfirm(build.transaction, {
|
|
526
559
|
blockhash: build.blockhash,
|
|
527
560
|
lastValidBlockHeight: build.lastValidBlockHeight,
|
|
528
561
|
skipPreflight: args.skipPreflight,
|
package/src/browser/index.ts
CHANGED
|
@@ -20,34 +20,40 @@ export {
|
|
|
20
20
|
} from "./storage.ts";
|
|
21
21
|
export { BrowserKeyVault, KeypairBrowserSigner } from "./wallet.ts";
|
|
22
22
|
export { buildLocalPumpBuy, buildLocalPumpSell } from "./pump.ts";
|
|
23
|
+
export { getSupportedPumpPairs, PumpPairService } from "@solard/core";
|
|
24
|
+
export type { PumpSupportedPair } from "@solard/core";
|
|
23
25
|
export {
|
|
24
26
|
PUMP_USDC_MINT,
|
|
25
27
|
buildPumpExternalDeployment,
|
|
26
28
|
resolvePumpQuoteAsset,
|
|
27
|
-
} from "@solard/core
|
|
29
|
+
} from "@solard/core";
|
|
28
30
|
export type {
|
|
29
31
|
PumpExternalDeploymentBuild,
|
|
30
32
|
PumpCustomPairSelection,
|
|
31
33
|
PumpLaunchPairInput,
|
|
32
|
-
} from "@solard/core
|
|
33
|
-
export { snapshotTokenHolders } from "@solard/core
|
|
34
|
+
} from "@solard/core";
|
|
35
|
+
export { snapshotTokenHolders } from "@solard/core";
|
|
34
36
|
export type {
|
|
35
37
|
TokenHolder,
|
|
36
38
|
ExcludedTokenHolder,
|
|
37
39
|
TokenHolderSnapshot,
|
|
38
40
|
TokenHolderSnapshotOptions,
|
|
39
|
-
} from "@solard/core
|
|
40
|
-
export { subscribeTokenEvents } from "@solard/core
|
|
41
|
+
} from "@solard/core";
|
|
42
|
+
export { subscribeTokenEvents } from "@solard/core";
|
|
41
43
|
export type {
|
|
44
|
+
SolardTokenCreateEvent,
|
|
42
45
|
SolardTokenEvent,
|
|
43
46
|
SolardTokenSwapEvent,
|
|
44
47
|
SolardTokenTransferEvent,
|
|
48
|
+
SolardTokenTransferMovement,
|
|
49
|
+
SolardTokenTransferSource,
|
|
45
50
|
SubscribeTokenEventsOptions,
|
|
46
51
|
TokenEventSubscription,
|
|
47
|
-
} from "@solard/core
|
|
52
|
+
} from "@solard/core";
|
|
48
53
|
|
|
49
54
|
export type {
|
|
50
|
-
|
|
55
|
+
BrowserConfirmedTransaction,
|
|
56
|
+
BrowserTransactionSubmission,
|
|
51
57
|
BrowserContact,
|
|
52
58
|
BrowserPortfolio,
|
|
53
59
|
BrowserPumpDeploymentBuild,
|
package/src/browser/pump.ts
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
type TransactionInstruction,
|
|
8
8
|
} from "@solana/web3.js";
|
|
9
9
|
|
|
10
|
-
import { readMint } from "@solard/core
|
|
11
|
-
import { rawAmount } from "@solard/core
|
|
12
|
-
import type { TokenRow } from "@solard/core
|
|
13
|
-
import { PumpCurveVenue } from "@solard/core
|
|
14
|
-
import { PumpSwapVenue } from "@solard/core
|
|
15
|
-
import { VenueRegistry } from "@solard/core
|
|
10
|
+
import { readMint } from "@solard/core";
|
|
11
|
+
import { rawAmount } from "@solard/core";
|
|
12
|
+
import type { TokenRow } from "@solard/core";
|
|
13
|
+
import { PumpCurveVenue } from "@solard/core";
|
|
14
|
+
import { PumpSwapVenue } from "@solard/core";
|
|
15
|
+
import { VenueRegistry } from "@solard/core";
|
|
16
16
|
|
|
17
17
|
import type { BrowserTradeBuild } from "./types.ts";
|
|
18
18
|
|
package/src/browser/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PumpExternalDeploymentBuild } from "@solard/core";
|
|
1
2
|
import type {
|
|
2
3
|
PublicKey,
|
|
3
4
|
Transaction,
|
|
@@ -55,13 +56,16 @@ export type BrowserPortfolio = {
|
|
|
55
56
|
tokenBalances: BrowserTokenBalance[];
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
export type
|
|
59
|
+
export type BrowserTransactionSubmission = {
|
|
59
60
|
signature: string;
|
|
60
|
-
confirmed: boolean;
|
|
61
61
|
blockhash: string;
|
|
62
62
|
lastValidBlockHeight: number;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
export type BrowserConfirmedTransaction = BrowserTransactionSubmission & {
|
|
66
|
+
status: "confirmed";
|
|
67
|
+
};
|
|
68
|
+
|
|
65
69
|
export type BrowserTradeSide = "buy" | "sell";
|
|
66
70
|
|
|
67
71
|
export type BrowserTradeBuild = {
|
|
@@ -79,7 +83,7 @@ export type BrowserTradeBuild = {
|
|
|
79
83
|
serializedSize: number;
|
|
80
84
|
};
|
|
81
85
|
|
|
82
|
-
export type BrowserTradeResult =
|
|
86
|
+
export type BrowserTradeResult = BrowserConfirmedTransaction & {
|
|
83
87
|
side: BrowserTradeSide;
|
|
84
88
|
venue: string;
|
|
85
89
|
mint: string;
|
|
@@ -97,10 +101,9 @@ export type BrowserSolardOptions = {
|
|
|
97
101
|
rpcMaxRps?: number;
|
|
98
102
|
fetch?: typeof globalThis.fetch;
|
|
99
103
|
};
|
|
100
|
-
export type BrowserPumpDeploymentBuild =
|
|
101
|
-
import("@solard/core/launches/pump/external-deployment.ts").PumpExternalDeploymentBuild;
|
|
104
|
+
export type BrowserPumpDeploymentBuild = PumpExternalDeploymentBuild;
|
|
102
105
|
|
|
103
|
-
export type BrowserPumpDeploymentResult =
|
|
106
|
+
export type BrowserPumpDeploymentResult = BrowserConfirmedTransaction & {
|
|
104
107
|
mint: string;
|
|
105
108
|
beneficiary: string;
|
|
106
109
|
quoteMint: string;
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTraderSolard as createCoreSolard,
|
|
3
|
+
type ClaimCreatorRewardsOptions,
|
|
4
|
+
type CreatorRewardClaimResult,
|
|
5
|
+
type CumulativeDistributionExecuteOptions,
|
|
6
|
+
type CumulativeDistributionInput,
|
|
7
|
+
type CumulativeDistributionPlan,
|
|
8
|
+
type CumulativeDistributionState,
|
|
9
|
+
type HumanAmount,
|
|
10
|
+
type MarketHistory,
|
|
11
|
+
type MarketHistoryOptions,
|
|
12
|
+
type MarketPrice,
|
|
13
|
+
type MergedReplayEventStream,
|
|
14
|
+
type ReplayEventSubscription,
|
|
15
|
+
type ReplayHistory,
|
|
16
|
+
type ReplayItem,
|
|
17
|
+
type ReplayOptions,
|
|
18
|
+
type ReplayEventsOptions,
|
|
19
|
+
type TokenHolderSnapshot,
|
|
20
|
+
type TokenHolderSnapshotOptions,
|
|
21
|
+
type TokenRef,
|
|
22
|
+
type WalletRef,
|
|
23
|
+
} from "@solard/core";
|
|
24
|
+
|
|
25
|
+
export type SolardOptions = {
|
|
26
|
+
rpcUrl?: string;
|
|
27
|
+
dbPath?: string;
|
|
28
|
+
cacheTtlMs?: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type SolardHistoryApi = {
|
|
32
|
+
replay(token: TokenRef, options?: ReplayOptions): Promise<ReplayHistory>;
|
|
33
|
+
market(
|
|
34
|
+
token: TokenRef,
|
|
35
|
+
options?: MarketHistoryOptions,
|
|
36
|
+
): Promise<MarketHistory>;
|
|
37
|
+
merge(
|
|
38
|
+
histories: readonly (ReplayHistory | Iterable<ReplayItem>)[],
|
|
39
|
+
): ReplayItem[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type SolardEventsApi = {
|
|
43
|
+
(
|
|
44
|
+
token: TokenRef,
|
|
45
|
+
options?: ReplayEventsOptions,
|
|
46
|
+
): Promise<ReplayEventSubscription>;
|
|
47
|
+
merge(streams: readonly ReplayEventSubscription[]): MergedReplayEventStream;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type Solard = {
|
|
51
|
+
close(): void;
|
|
52
|
+
history: SolardHistoryApi;
|
|
53
|
+
events: SolardEventsApi;
|
|
54
|
+
claims: {
|
|
55
|
+
creatorFees: {
|
|
56
|
+
claim(
|
|
57
|
+
token: TokenRef,
|
|
58
|
+
wallet: WalletRef,
|
|
59
|
+
options?: ClaimCreatorRewardsOptions,
|
|
60
|
+
): Promise<CreatorRewardClaimResult>;
|
|
61
|
+
status(
|
|
62
|
+
id: string,
|
|
63
|
+
): ReturnType<
|
|
64
|
+
ReturnType<typeof createCoreSolard>["claims"]["creatorFees"]["status"]
|
|
65
|
+
>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
distributions: {
|
|
69
|
+
plan(
|
|
70
|
+
options: CumulativeDistributionInput,
|
|
71
|
+
): Promise<CumulativeDistributionPlan>;
|
|
72
|
+
execute(
|
|
73
|
+
options: CumulativeDistributionExecuteOptions,
|
|
74
|
+
): Promise<CumulativeDistributionState>;
|
|
75
|
+
status(id: string): CumulativeDistributionState | null;
|
|
76
|
+
};
|
|
77
|
+
createWallet: ReturnType<typeof createCoreSolard>["createWallet"];
|
|
78
|
+
createVanityWallet: ReturnType<typeof createCoreSolard>["createVanityWallet"];
|
|
79
|
+
importWallet: ReturnType<typeof createCoreSolard>["importWallet"];
|
|
80
|
+
listWallets: ReturnType<typeof createCoreSolard>["listWallets"];
|
|
81
|
+
addToken: ReturnType<typeof createCoreSolard>["addToken"];
|
|
82
|
+
resolveToken: ReturnType<typeof createCoreSolard>["resolveToken"];
|
|
83
|
+
tokenAccounts: ReturnType<typeof createCoreSolard>["tokenAccounts"];
|
|
84
|
+
snapshotHolders(
|
|
85
|
+
token: TokenRef,
|
|
86
|
+
options?: Omit<TokenHolderSnapshotOptions, "token">,
|
|
87
|
+
): Promise<TokenHolderSnapshot>;
|
|
88
|
+
walletBalances: ReturnType<typeof createCoreSolard>["walletBalances"];
|
|
89
|
+
samplePrice(token: TokenRef): Promise<MarketPrice>;
|
|
90
|
+
buy(
|
|
91
|
+
token: TokenRef,
|
|
92
|
+
wallet: WalletRef,
|
|
93
|
+
amount: HumanAmount,
|
|
94
|
+
options?: Parameters<ReturnType<typeof createCoreSolard>["buy"]>[3],
|
|
95
|
+
): ReturnType<ReturnType<typeof createCoreSolard>["buy"]>;
|
|
96
|
+
sell: ReturnType<typeof createCoreSolard>["sell"];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export function createSolard(options: SolardOptions = {}): Solard {
|
|
100
|
+
const core = createCoreSolard(options);
|
|
101
|
+
const history: SolardHistoryApi = Object.freeze({
|
|
102
|
+
replay: (token, replayOptions) => core.history.replay(token, replayOptions),
|
|
103
|
+
market: (token, marketOptions) => core.history.market(token, marketOptions),
|
|
104
|
+
merge: core.history.merge,
|
|
105
|
+
});
|
|
106
|
+
const events = Object.assign(
|
|
107
|
+
(token: TokenRef, eventOptions: ReplayEventsOptions = {}) =>
|
|
108
|
+
core.events(token, eventOptions),
|
|
109
|
+
{ merge: core.events.merge },
|
|
110
|
+
) as SolardEventsApi;
|
|
111
|
+
return Object.freeze({
|
|
112
|
+
close: core.close.bind(core),
|
|
113
|
+
history,
|
|
114
|
+
events: Object.freeze(events),
|
|
115
|
+
claims: Object.freeze({
|
|
116
|
+
creatorFees: Object.freeze({
|
|
117
|
+
claim: core.claims.creatorFees.claim,
|
|
118
|
+
status: core.claims.creatorFees.status,
|
|
119
|
+
}),
|
|
120
|
+
}),
|
|
121
|
+
distributions: Object.freeze({
|
|
122
|
+
plan: core.distributions.plan,
|
|
123
|
+
execute: core.distributions.execute,
|
|
124
|
+
status: core.distributions.status,
|
|
125
|
+
}),
|
|
126
|
+
createWallet: core.createWallet.bind(core),
|
|
127
|
+
createVanityWallet: core.createVanityWallet.bind(core),
|
|
128
|
+
importWallet: core.importWallet.bind(core),
|
|
129
|
+
listWallets: core.listWallets.bind(core),
|
|
130
|
+
addToken: core.addToken.bind(core),
|
|
131
|
+
resolveToken: core.resolveToken.bind(core),
|
|
132
|
+
tokenAccounts: core.tokenAccounts.bind(core),
|
|
133
|
+
snapshotHolders: core.snapshotHolders.bind(core),
|
|
134
|
+
walletBalances: core.walletBalances.bind(core),
|
|
135
|
+
samplePrice: core.samplePrice.bind(core),
|
|
136
|
+
buy: core.buy.bind(core),
|
|
137
|
+
sell: core.sell.bind(core),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const createTraderSolard = createSolard;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const source = readFileSync(join(import.meta.dir, "index.ts"), "utf8");
|
|
6
|
+
const client = readFileSync(join(import.meta.dir, "client.ts"), "utf8");
|
|
7
|
+
|
|
8
|
+
function exportedNames(value: string) {
|
|
9
|
+
const values: string[] = [];
|
|
10
|
+
const types: string[] = [];
|
|
11
|
+
const pattern = /export\s+(type\s+)?\{([\s\S]*?)\}\s+from\s+["'][^"']+["'];/g;
|
|
12
|
+
for (const match of value.matchAll(pattern)) {
|
|
13
|
+
const target = match[1] ? types : values;
|
|
14
|
+
for (const raw of match[2]!.split(",")) {
|
|
15
|
+
const name =
|
|
16
|
+
raw.trim().split(/\s+as\s+/)[1] ?? raw.trim().split(/\s+as\s+/)[0];
|
|
17
|
+
if (name) target.push(name.trim());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
values: [...new Set(values)].sort(),
|
|
22
|
+
types: [...new Set(types)].sort(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe("sdk membrane", () => {
|
|
27
|
+
test("has an exact curated root export surface", () => {
|
|
28
|
+
expect(exportedNames(source)).toEqual({
|
|
29
|
+
values: [
|
|
30
|
+
"createSolard",
|
|
31
|
+
"createTraderSolard",
|
|
32
|
+
"formatRaw",
|
|
33
|
+
"sol",
|
|
34
|
+
"tokenAmount",
|
|
35
|
+
].sort(),
|
|
36
|
+
types: [
|
|
37
|
+
"ClaimCreatorRewardsOptions",
|
|
38
|
+
"CreatorRewardClaimPayout",
|
|
39
|
+
"CreatorRewardClaimResult",
|
|
40
|
+
"CumulativeDistributionExecuteOptions",
|
|
41
|
+
"CumulativeDistributionInput",
|
|
42
|
+
"CumulativeDistributionPlan",
|
|
43
|
+
"CumulativeDistributionRecipient",
|
|
44
|
+
"CumulativeDistributionState",
|
|
45
|
+
"CumulativeEntitlement",
|
|
46
|
+
"HumanAmount",
|
|
47
|
+
"MarketHistory",
|
|
48
|
+
"MarketHistoryOptions",
|
|
49
|
+
"MarketPrice",
|
|
50
|
+
"MergedReplayEventStream",
|
|
51
|
+
"QuoteAsset",
|
|
52
|
+
"ReplayCoverage",
|
|
53
|
+
"ReplayEventSubscription",
|
|
54
|
+
"ReplayEventsOptions",
|
|
55
|
+
"ReplayHistory",
|
|
56
|
+
"ReplayItem",
|
|
57
|
+
"ReplayOptions",
|
|
58
|
+
"ReplayPayout",
|
|
59
|
+
"ReplayTransaction",
|
|
60
|
+
"SendReceipt",
|
|
61
|
+
"SenderId",
|
|
62
|
+
"SimulationResult",
|
|
63
|
+
"Solard",
|
|
64
|
+
"SolardCanonicalEvent",
|
|
65
|
+
"SolardClaimAttribution",
|
|
66
|
+
"SolardClaimEvent",
|
|
67
|
+
"SolardEventsApi",
|
|
68
|
+
"SolardHistoryApi",
|
|
69
|
+
"SolardOptions",
|
|
70
|
+
"ExcludedTokenHolder",
|
|
71
|
+
"TokenHolder",
|
|
72
|
+
"TokenHolderSnapshot",
|
|
73
|
+
"TokenHolderSnapshotOptions",
|
|
74
|
+
"TokenEventHistoryProgress",
|
|
75
|
+
"TokenRef",
|
|
76
|
+
"TokenRow",
|
|
77
|
+
"WalletInfo",
|
|
78
|
+
"WalletRef",
|
|
79
|
+
].sort(),
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("does not wildcard-export or deep-import core", () => {
|
|
84
|
+
expect(source).not.toContain('export * from "@solard/core"');
|
|
85
|
+
expect(source).not.toMatch(/\.\.\/\.\.\/core\/src|@solard\/core\//);
|
|
86
|
+
expect(client).not.toMatch(/\.\.\/\.\.\/core\/src|@solard\/core\//);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("does not create persistence at module import", () => {
|
|
90
|
+
expect(source).not.toMatch(/createCoreSolard|createTraderSolard\(\)/);
|
|
91
|
+
expect(client.indexOf("createCoreSolard(options)")).toBeGreaterThan(
|
|
92
|
+
client.indexOf("export function createSolard"),
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("does not expose core repositories or secret-bearing handles", () => {
|
|
97
|
+
expect(client).not.toMatch(
|
|
98
|
+
/\b(?:db|wallets|tokens|groups|executions|positions|prices|alts|senders|venues|claimSources|launches|launchpads|connection|signer)\s*:/,
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
* Public Solard SDK.
|
|
3
|
-
*
|
|
4
|
-
* All stateful behavior lives in @solard/core so the SDK and CLI share exactly
|
|
5
|
-
* the same wallet store, transaction engine, venues, senders and database.
|
|
6
|
-
*/
|
|
7
|
-
export * from "@solard/core";
|
|
8
|
-
|
|
9
|
-
// Explicit source-level re-export for the generic Jupiter swap helpers.
|
|
10
|
-
// This avoids depending on the @solard/core package barrel resolution when the
|
|
11
|
-
// monorepo CLI is executed directly from source with Bun.
|
|
12
|
-
export {
|
|
13
|
-
executeJupiterSwap,
|
|
14
|
-
quoteJupiterSwap,
|
|
15
|
-
executeJupiterTokenToSol,
|
|
16
|
-
quoteJupiterTokenToSol,
|
|
17
|
-
} from "../../core/src/chain/jupiter-swap.ts";
|
|
1
|
+
export { createSolard, createTraderSolard } from "./client.ts";
|
|
18
2
|
export type {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
Solard,
|
|
4
|
+
SolardEventsApi,
|
|
5
|
+
SolardHistoryApi,
|
|
6
|
+
SolardOptions,
|
|
7
|
+
} from "./client.ts";
|
|
8
|
+
|
|
9
|
+
export { formatRaw, sol, tokenAmount } from "@solard/core";
|
|
23
10
|
|
|
24
|
-
// Direct source re-exports used by the source-executed CLI.
|
|
25
|
-
export { readMint } from "../../core/src/chain/state.ts";
|
|
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
11
|
export type {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
12
|
+
ClaimCreatorRewardsOptions,
|
|
13
|
+
CreatorRewardClaimPayout,
|
|
14
|
+
CreatorRewardClaimResult,
|
|
15
|
+
CumulativeDistributionExecuteOptions,
|
|
16
|
+
CumulativeDistributionInput,
|
|
17
|
+
CumulativeDistributionPlan,
|
|
18
|
+
CumulativeDistributionRecipient,
|
|
19
|
+
CumulativeDistributionState,
|
|
20
|
+
CumulativeEntitlement,
|
|
21
|
+
HumanAmount,
|
|
22
|
+
MarketHistory,
|
|
23
|
+
MarketHistoryOptions,
|
|
24
|
+
MarketPrice,
|
|
25
|
+
MergedReplayEventStream,
|
|
26
|
+
QuoteAsset,
|
|
27
|
+
ReplayCoverage,
|
|
28
|
+
ReplayEventSubscription,
|
|
29
|
+
ReplayEventsOptions,
|
|
30
|
+
ReplayHistory,
|
|
31
|
+
ReplayItem,
|
|
32
|
+
ReplayOptions,
|
|
33
|
+
ReplayPayout,
|
|
34
|
+
ReplayTransaction,
|
|
35
|
+
SendReceipt,
|
|
36
|
+
SenderId,
|
|
37
|
+
SimulationResult,
|
|
38
|
+
SolardCanonicalEvent,
|
|
39
|
+
SolardClaimAttribution,
|
|
40
|
+
SolardClaimEvent,
|
|
41
|
+
TokenEventHistoryProgress,
|
|
42
|
+
TokenHolder,
|
|
43
|
+
ExcludedTokenHolder,
|
|
44
|
+
TokenHolderSnapshot,
|
|
45
|
+
TokenHolderSnapshotOptions,
|
|
46
|
+
TokenRef,
|
|
47
|
+
TokenRow,
|
|
48
|
+
WalletInfo,
|
|
49
|
+
WalletRef,
|
|
50
|
+
} from "@solard/core";
|