@solard/sdk 0.2.37 → 0.2.40
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/dist/types/browser/client.d.ts +129 -0
- package/dist/types/browser/index.d.ts +19 -0
- package/dist/types/browser/pump.d.ts +20 -0
- package/dist/types/browser/storage.d.ts +34 -0
- package/dist/types/browser/types.d.ts +90 -0
- package/dist/types/browser/wallet.d.ts +37 -0
- package/dist/types/client.d.ts +117 -0
- package/dist/types/default.d.ts +10 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/live.d.ts +60 -0
- package/dist/types/protocol.d.ts +2 -0
- package/package.json +14 -8
- package/src/client.ts +33 -4
- package/src/export-surface.test.ts +12 -2
- package/src/index.ts +7 -1
- package/src/live-recovery.test.ts +122 -0
- package/src/live.test.ts +53 -10
- package/src/live.ts +178 -69
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Connection, PublicKey, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { type PumpLaunchPairInput } from "@solard/core";
|
|
3
|
+
import { type TokenHolderSnapshotOptions } from "@solard/core";
|
|
4
|
+
import { type SubscribeTokenEventsOptions, type TokenEventSubscription } from "@solard/core";
|
|
5
|
+
import { PumpPairService } from "@solard/core";
|
|
6
|
+
import { BrowserSolardStore } from "./storage.js";
|
|
7
|
+
import type { BrowserConfirmedTransaction, BrowserTransactionSubmission, BrowserPortfolio, BrowserPumpDeploymentBuild, BrowserPumpDeploymentResult, BrowserSolardOptions, BrowserTradeBuild, BrowserTradeResult, BrowserWalletSigner } from "./types.js";
|
|
8
|
+
export declare const SOL_MINT = "So11111111111111111111111111111111111111112";
|
|
9
|
+
export declare const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
10
|
+
export declare const TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
11
|
+
export declare const TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
12
|
+
export declare class BrowserSolard {
|
|
13
|
+
readonly options: BrowserSolardOptions;
|
|
14
|
+
readonly connection: Connection;
|
|
15
|
+
readonly store: BrowserSolardStore;
|
|
16
|
+
readonly contacts: {
|
|
17
|
+
list: () => import("./types.js").BrowserContact[];
|
|
18
|
+
add: (name: string, address: string, addOptions?: {
|
|
19
|
+
overwrite?: boolean;
|
|
20
|
+
}) => import("./types.js").BrowserContact;
|
|
21
|
+
find: (ref: string) => import("./types.js").BrowserContact | null;
|
|
22
|
+
remove: (ref: string) => import("./types.js").BrowserContact;
|
|
23
|
+
resolve: (ref: string) => string;
|
|
24
|
+
};
|
|
25
|
+
readonly tokens: {
|
|
26
|
+
list: () => import("./types.js").BrowserTokenAlias[];
|
|
27
|
+
register: (alias: string, mint: string, registerOptions?: {
|
|
28
|
+
overwrite?: boolean;
|
|
29
|
+
}) => import("./types.js").BrowserTokenAlias;
|
|
30
|
+
resolve: (ref: string) => string;
|
|
31
|
+
};
|
|
32
|
+
readonly pump: PumpPairService;
|
|
33
|
+
readonly events: {
|
|
34
|
+
subscribeToken: (token: string, options?: SubscribeTokenEventsOptions) => Promise<TokenEventSubscription>;
|
|
35
|
+
};
|
|
36
|
+
private wallet;
|
|
37
|
+
constructor(options: BrowserSolardOptions);
|
|
38
|
+
setWallet(wallet: BrowserWalletSigner | null): void;
|
|
39
|
+
get publicKey(): PublicKey | null;
|
|
40
|
+
private signer;
|
|
41
|
+
connectWallet(): Promise<PublicKey>;
|
|
42
|
+
resolveDestination(ref: string): string;
|
|
43
|
+
resolveToken(ref: string): string;
|
|
44
|
+
private resolveTokenOrMint;
|
|
45
|
+
private inspectPumpToken;
|
|
46
|
+
/** Complete holder snapshot suitable for reward allocation. */
|
|
47
|
+
snapshotHolders(token: string, options?: Omit<TokenHolderSnapshotOptions, "token">): Promise<import("@solard/core").TokenHolderSnapshot>;
|
|
48
|
+
/** Typed Pump/PumpSwap swap and mint-mentioned transfer stream. */
|
|
49
|
+
subscribeTokenEvents(token: string, options?: SubscribeTokenEventsOptions): Promise<TokenEventSubscription>;
|
|
50
|
+
getPortfolio(address?: string | PublicKey): Promise<BrowserPortfolio>;
|
|
51
|
+
submitTransaction(transaction: VersionedTransaction, strategy: {
|
|
52
|
+
blockhash: string;
|
|
53
|
+
lastValidBlockHeight: number;
|
|
54
|
+
skipPreflight?: boolean;
|
|
55
|
+
}): Promise<BrowserTransactionSubmission>;
|
|
56
|
+
confirmSubmission(submission: BrowserTransactionSubmission): Promise<BrowserConfirmedTransaction>;
|
|
57
|
+
private submitAndConfirm;
|
|
58
|
+
sendSol(destinationRef: string, amountSol: string | number): Promise<BrowserConfirmedTransaction>;
|
|
59
|
+
/**
|
|
60
|
+
* Build a Pump create_v2 transaction for the connected wallet without asking
|
|
61
|
+
* it to sign and without broadcasting. The generated mint signature is already
|
|
62
|
+
* present; the connected wallet remains the missing payer signature.
|
|
63
|
+
*/
|
|
64
|
+
buildPumpDeployment(args: {
|
|
65
|
+
name: string;
|
|
66
|
+
symbol: string;
|
|
67
|
+
uri: string;
|
|
68
|
+
pair?: PumpLaunchPairInput;
|
|
69
|
+
beneficiary?: string | PublicKey;
|
|
70
|
+
mayhemMode?: boolean;
|
|
71
|
+
cashback?: boolean;
|
|
72
|
+
cuLimit?: number;
|
|
73
|
+
priorityMicroLamports?: number;
|
|
74
|
+
}): Promise<BrowserPumpDeploymentBuild>;
|
|
75
|
+
/** Build, request the wallet signature, broadcast, and confirm a Pump launch. */
|
|
76
|
+
deployPump(args: {
|
|
77
|
+
name: string;
|
|
78
|
+
symbol: string;
|
|
79
|
+
uri: string;
|
|
80
|
+
pair?: PumpLaunchPairInput;
|
|
81
|
+
beneficiary?: string | PublicKey;
|
|
82
|
+
mayhemMode?: boolean;
|
|
83
|
+
cashback?: boolean;
|
|
84
|
+
cuLimit?: number;
|
|
85
|
+
priorityMicroLamports?: number;
|
|
86
|
+
skipPreflight?: boolean;
|
|
87
|
+
}): Promise<BrowserPumpDeploymentResult>;
|
|
88
|
+
buildBuy(args: {
|
|
89
|
+
token: string;
|
|
90
|
+
sol: string | number;
|
|
91
|
+
slippageBps?: number;
|
|
92
|
+
cuLimit?: number;
|
|
93
|
+
priorityMicroLamports?: number;
|
|
94
|
+
}): Promise<BrowserTradeBuild>;
|
|
95
|
+
buildSell(args: {
|
|
96
|
+
token: string;
|
|
97
|
+
amountRaw: bigint;
|
|
98
|
+
slippageBps?: number;
|
|
99
|
+
cuLimit?: number;
|
|
100
|
+
priorityMicroLamports?: number;
|
|
101
|
+
}): Promise<BrowserTradeBuild>;
|
|
102
|
+
buy(args: {
|
|
103
|
+
token: string;
|
|
104
|
+
sol: string | number;
|
|
105
|
+
slippageBps?: number;
|
|
106
|
+
cuLimit?: number;
|
|
107
|
+
priorityMicroLamports?: number;
|
|
108
|
+
skipPreflight?: boolean;
|
|
109
|
+
}): Promise<BrowserTradeResult>;
|
|
110
|
+
sell(args: {
|
|
111
|
+
token: string;
|
|
112
|
+
amountRaw: bigint;
|
|
113
|
+
slippageBps?: number;
|
|
114
|
+
cuLimit?: number;
|
|
115
|
+
priorityMicroLamports?: number;
|
|
116
|
+
skipPreflight?: boolean;
|
|
117
|
+
}): Promise<BrowserTradeResult>;
|
|
118
|
+
buyWithSol(args: {
|
|
119
|
+
outputMint: string;
|
|
120
|
+
sol: string | number;
|
|
121
|
+
slippageBps?: number;
|
|
122
|
+
}): Promise<BrowserTradeResult>;
|
|
123
|
+
sellToSol(args: {
|
|
124
|
+
inputMint: string;
|
|
125
|
+
amountRaw: bigint;
|
|
126
|
+
slippageBps?: number;
|
|
127
|
+
}): Promise<BrowserTradeResult>;
|
|
128
|
+
}
|
|
129
|
+
export declare function createBrowserSolard(options: BrowserSolardOptions): BrowserSolard;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe Solard SDK.
|
|
3
|
+
*
|
|
4
|
+
* Trading uses the same local Pump/PumpSwap venue classes, quote math and
|
|
5
|
+
* instruction builders as the CLI/core engine. No external swap API is used.
|
|
6
|
+
*/
|
|
7
|
+
export { BrowserSolard, SOL_MINT, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, USDC_MINT, createBrowserSolard, } from "./client.js";
|
|
8
|
+
export { BrowserSolardStore, MemoryBrowserStorage, defaultBrowserStorage, } from "./storage.js";
|
|
9
|
+
export { BrowserKeyVault, KeypairBrowserSigner } from "./wallet.js";
|
|
10
|
+
export { buildLocalPumpBuy, buildLocalPumpSell } from "./pump.js";
|
|
11
|
+
export { getSupportedPumpPairs, PumpPairService } from "@solard/core";
|
|
12
|
+
export type { PumpSupportedPair } from "@solard/core";
|
|
13
|
+
export { PUMP_USDC_MINT, buildPumpExternalDeployment, resolvePumpQuoteAsset, } from "@solard/core";
|
|
14
|
+
export type { PumpExternalDeploymentBuild, PumpCustomPairSelection, PumpLaunchPairInput, } from "@solard/core";
|
|
15
|
+
export { snapshotTokenHolders } from "@solard/core";
|
|
16
|
+
export type { TokenHolder, ExcludedTokenHolder, TokenHolderSnapshot, TokenHolderSnapshotOptions, } from "@solard/core";
|
|
17
|
+
export { subscribeTokenEvents } from "@solard/core";
|
|
18
|
+
export type { SolardTokenCreateEvent, SolardTokenEvent, SolardTokenSwapEvent, SolardTokenTransferEvent, SolardTokenTransferMovement, SolardTokenTransferSource, SubscribeTokenEventsOptions, TokenEventSubscription, } from "@solard/core";
|
|
19
|
+
export type { BrowserConfirmedTransaction, BrowserTransactionSubmission, BrowserContact, BrowserPortfolio, BrowserPumpDeploymentBuild, BrowserPumpDeploymentResult, BrowserSolardOptions, BrowserStorageLike, BrowserTokenAlias, BrowserTokenBalance, BrowserTradeBuild, BrowserTradeResult, BrowserTradeSide, BrowserWalletSigner, } from "./types.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PublicKey, type Connection } from "@solana/web3.js";
|
|
2
|
+
import type { BrowserTradeBuild } from "./types.js";
|
|
3
|
+
export declare function buildLocalPumpBuy(args: {
|
|
4
|
+
connection: Connection;
|
|
5
|
+
user: PublicKey;
|
|
6
|
+
mint: string | PublicKey;
|
|
7
|
+
quoteInRaw: bigint;
|
|
8
|
+
slippageBps?: number;
|
|
9
|
+
cuLimit?: number;
|
|
10
|
+
priorityMicroLamports?: number;
|
|
11
|
+
}): Promise<BrowserTradeBuild>;
|
|
12
|
+
export declare function buildLocalPumpSell(args: {
|
|
13
|
+
connection: Connection;
|
|
14
|
+
user: PublicKey;
|
|
15
|
+
mint: string | PublicKey;
|
|
16
|
+
baseInRaw: bigint;
|
|
17
|
+
slippageBps?: number;
|
|
18
|
+
cuLimit?: number;
|
|
19
|
+
priorityMicroLamports?: number;
|
|
20
|
+
}): Promise<BrowserTradeBuild>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BrowserContact, BrowserStorageLike, BrowserTokenAlias } from "./types.js";
|
|
2
|
+
export declare class MemoryBrowserStorage implements BrowserStorageLike {
|
|
3
|
+
private readonly values;
|
|
4
|
+
get length(): number;
|
|
5
|
+
clear(): void;
|
|
6
|
+
getItem(key: string): string | null;
|
|
7
|
+
key(index: number): string | null;
|
|
8
|
+
removeItem(key: string): void;
|
|
9
|
+
setItem(key: string, value: string): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function defaultBrowserStorage(): BrowserStorageLike;
|
|
12
|
+
export declare class BrowserSolardStore {
|
|
13
|
+
readonly storage: BrowserStorageLike;
|
|
14
|
+
readonly namespace: string;
|
|
15
|
+
constructor(storage?: BrowserStorageLike, namespace?: string);
|
|
16
|
+
private key;
|
|
17
|
+
private readCollection;
|
|
18
|
+
private writeCollection;
|
|
19
|
+
listContacts(): BrowserContact[];
|
|
20
|
+
addContact(nameInput: string, addressInput: string, options?: {
|
|
21
|
+
overwrite?: boolean;
|
|
22
|
+
}): BrowserContact;
|
|
23
|
+
findContact(ref: string): BrowserContact | null;
|
|
24
|
+
removeContact(ref: string): BrowserContact;
|
|
25
|
+
listTokenAliases(): BrowserTokenAlias[];
|
|
26
|
+
registerToken(aliasInput: string, mintInput: string, options?: {
|
|
27
|
+
overwrite?: boolean;
|
|
28
|
+
}): BrowserTokenAlias;
|
|
29
|
+
resolveToken(ref: string): string;
|
|
30
|
+
setSetting<T>(name: string, value: T): void;
|
|
31
|
+
getSetting<T>(name: string, fallback: T): T;
|
|
32
|
+
removeSetting(name: string): void;
|
|
33
|
+
resolveDestination(ref: string): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { PumpExternalDeploymentBuild } from "@solard/core";
|
|
2
|
+
import type { PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
3
|
+
export interface BrowserWalletSigner {
|
|
4
|
+
publicKey: PublicKey | null;
|
|
5
|
+
connect?: () => Promise<unknown>;
|
|
6
|
+
disconnect?: () => Promise<unknown>;
|
|
7
|
+
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
|
|
8
|
+
signAllTransactions?<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
|
|
9
|
+
}
|
|
10
|
+
export interface BrowserStorageLike {
|
|
11
|
+
readonly length: number;
|
|
12
|
+
clear(): void;
|
|
13
|
+
getItem(key: string): string | null;
|
|
14
|
+
key(index: number): string | null;
|
|
15
|
+
removeItem(key: string): void;
|
|
16
|
+
setItem(key: string, value: string): void;
|
|
17
|
+
}
|
|
18
|
+
export type BrowserContact = {
|
|
19
|
+
name: string;
|
|
20
|
+
address: string;
|
|
21
|
+
createdAtMs: number;
|
|
22
|
+
updatedAtMs: number;
|
|
23
|
+
};
|
|
24
|
+
export type BrowserTokenAlias = {
|
|
25
|
+
alias: string;
|
|
26
|
+
mint: string;
|
|
27
|
+
createdAtMs: number;
|
|
28
|
+
updatedAtMs: number;
|
|
29
|
+
};
|
|
30
|
+
export type BrowserTokenBalance = {
|
|
31
|
+
mint: string;
|
|
32
|
+
amountRaw: bigint;
|
|
33
|
+
amountUi: string;
|
|
34
|
+
decimals: number;
|
|
35
|
+
program: "spl-token" | "token-2022";
|
|
36
|
+
label: string;
|
|
37
|
+
tokenAccounts: string[];
|
|
38
|
+
};
|
|
39
|
+
export type BrowserPortfolio = {
|
|
40
|
+
address: string;
|
|
41
|
+
solLamports: bigint;
|
|
42
|
+
tokenBalances: BrowserTokenBalance[];
|
|
43
|
+
};
|
|
44
|
+
export type BrowserTransactionSubmission = {
|
|
45
|
+
signature: string;
|
|
46
|
+
blockhash: string;
|
|
47
|
+
lastValidBlockHeight: number;
|
|
48
|
+
};
|
|
49
|
+
export type BrowserConfirmedTransaction = BrowserTransactionSubmission & {
|
|
50
|
+
status: "confirmed";
|
|
51
|
+
};
|
|
52
|
+
export type BrowserTradeSide = "buy" | "sell";
|
|
53
|
+
export type BrowserTradeBuild = {
|
|
54
|
+
transaction: VersionedTransaction;
|
|
55
|
+
side: BrowserTradeSide;
|
|
56
|
+
venue: string;
|
|
57
|
+
mint: string;
|
|
58
|
+
inputRaw: bigint;
|
|
59
|
+
expectedOutputRaw: bigint;
|
|
60
|
+
minimumOutputRaw: bigint;
|
|
61
|
+
quoteMint: string;
|
|
62
|
+
quoteDecimals: number;
|
|
63
|
+
blockhash: string;
|
|
64
|
+
lastValidBlockHeight: number;
|
|
65
|
+
serializedSize: number;
|
|
66
|
+
};
|
|
67
|
+
export type BrowserTradeResult = BrowserConfirmedTransaction & {
|
|
68
|
+
side: BrowserTradeSide;
|
|
69
|
+
venue: string;
|
|
70
|
+
mint: string;
|
|
71
|
+
inputRaw: bigint;
|
|
72
|
+
expectedOutputRaw: bigint;
|
|
73
|
+
minimumOutputRaw: bigint;
|
|
74
|
+
};
|
|
75
|
+
export type BrowserSolardOptions = {
|
|
76
|
+
rpcUrl: string;
|
|
77
|
+
wallet?: BrowserWalletSigner | null;
|
|
78
|
+
storage?: BrowserStorageLike;
|
|
79
|
+
storageNamespace?: string;
|
|
80
|
+
commitment?: "processed" | "confirmed" | "finalized";
|
|
81
|
+
rpcMaxRps?: number;
|
|
82
|
+
fetch?: typeof globalThis.fetch;
|
|
83
|
+
};
|
|
84
|
+
export type BrowserPumpDeploymentBuild = PumpExternalDeploymentBuild;
|
|
85
|
+
export type BrowserPumpDeploymentResult = BrowserConfirmedTransaction & {
|
|
86
|
+
mint: string;
|
|
87
|
+
beneficiary: string;
|
|
88
|
+
quoteMint: string;
|
|
89
|
+
quoteKind: "native-sol" | "spl-token";
|
|
90
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Keypair, Transaction, VersionedTransaction, type PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { BrowserStorageLike, BrowserWalletSigner } from "./types.js";
|
|
3
|
+
export declare class KeypairBrowserSigner implements BrowserWalletSigner {
|
|
4
|
+
private readonly keypair;
|
|
5
|
+
readonly publicKey: PublicKey;
|
|
6
|
+
constructor(keypair: Keypair);
|
|
7
|
+
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
|
|
8
|
+
signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Optional local-key mode for browser-only apps.
|
|
12
|
+
*
|
|
13
|
+
* Secret bytes are AES-GCM encrypted before being written to localStorage.
|
|
14
|
+
* For user-facing trading apps, an injected wallet extension remains the
|
|
15
|
+
* preferred signer because XSS can access any origin's localStorage.
|
|
16
|
+
*/
|
|
17
|
+
export declare class BrowserKeyVault {
|
|
18
|
+
private readonly storage;
|
|
19
|
+
private readonly namespace;
|
|
20
|
+
constructor(storage?: BrowserStorageLike, namespace?: string);
|
|
21
|
+
private key;
|
|
22
|
+
list(): Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
publicKey: string;
|
|
25
|
+
createdAtMs: number;
|
|
26
|
+
}>;
|
|
27
|
+
save(nameInput: string, keypair: Keypair, password: string, options?: {
|
|
28
|
+
overwrite?: boolean;
|
|
29
|
+
iterations?: number;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
generate(name: string, password: string, options?: {
|
|
32
|
+
overwrite?: boolean;
|
|
33
|
+
iterations?: number;
|
|
34
|
+
}): Promise<KeypairBrowserSigner>;
|
|
35
|
+
unlock(nameInput: string, password: string): Promise<KeypairBrowserSigner>;
|
|
36
|
+
remove(name: string): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { createTraderSolard as createCoreSolard, type ClaimCreatorRewardsOptions, type CreatorRewardClaimResult, type CumulativeDistributionExecuteOptions, type CumulativeDistributionInput, type CumulativeDistributionPlan, type CumulativeDistributionState, type HumanAmount, type MarketHistory, type MarketHistoryOptions, type MarketPrice, type MergedReplayEventStream, type ReplayEventSubscription, type ReplayHistory, type ReplayItem, type ReplayOptions, type ReplayEventsOptions, type RecordConfirmedTradeInput, type TradeResult, type TradeExecutionOptions, type LivePoolReserves, type SolardDecodedTransaction, type SolardTransactionOptions, type SolardPosition, type SolardPositionQuery, type SolardTrade, type SolardTradeQuery, type TokenHolderSnapshot, type TokenHolderSnapshotOptions, type TokenRef, type WalletRef, type WalletPrivateKeyExport, type WalletPrivateKeyFormat } from "@solard/core";
|
|
2
|
+
import { type ListenTradesOptions, type TradeListener } from "./live.js";
|
|
3
|
+
export type SolardOptions = {
|
|
4
|
+
transactionVersion?: 0 | 1;
|
|
5
|
+
rpcUrl?: string;
|
|
6
|
+
rpcUrls?: readonly string[];
|
|
7
|
+
websocketUrls?: readonly string[];
|
|
8
|
+
dbPath?: string;
|
|
9
|
+
cacheTtlMs?: number;
|
|
10
|
+
};
|
|
11
|
+
export type SolardHistoryApi = {
|
|
12
|
+
replay(token: TokenRef, options?: ReplayOptions): Promise<ReplayHistory>;
|
|
13
|
+
market(token: TokenRef, options?: MarketHistoryOptions): Promise<MarketHistory>;
|
|
14
|
+
merge(histories: readonly (ReplayHistory | Iterable<ReplayItem>)[]): ReplayItem[];
|
|
15
|
+
};
|
|
16
|
+
export type SolardEventsApi = {
|
|
17
|
+
(token: TokenRef, options?: ReplayEventsOptions): Promise<ReplayEventSubscription>;
|
|
18
|
+
merge(streams: readonly ReplayEventSubscription[]): MergedReplayEventStream;
|
|
19
|
+
};
|
|
20
|
+
export type SolardBuyInput = {
|
|
21
|
+
reserves?: LivePoolReserves;
|
|
22
|
+
maxPriceSol?: string | number;
|
|
23
|
+
wallet: WalletRef;
|
|
24
|
+
token: TokenRef;
|
|
25
|
+
amount: HumanAmount | string | number;
|
|
26
|
+
slippageBps?: number;
|
|
27
|
+
minOutputRaw?: bigint | string;
|
|
28
|
+
};
|
|
29
|
+
export type SolardSellInput = {
|
|
30
|
+
closeTokenAccount?: boolean;
|
|
31
|
+
reserves?: LivePoolReserves;
|
|
32
|
+
minPriceSol?: string | number;
|
|
33
|
+
wallet: WalletRef;
|
|
34
|
+
token: TokenRef;
|
|
35
|
+
amount?: "all" | {
|
|
36
|
+
bps: number;
|
|
37
|
+
} | {
|
|
38
|
+
raw: bigint | string;
|
|
39
|
+
};
|
|
40
|
+
/** Exact raw token units; mutually exclusive with amount. */
|
|
41
|
+
amountRaw?: bigint | string;
|
|
42
|
+
slippageBps?: number;
|
|
43
|
+
minOutputLamports?: bigint | string;
|
|
44
|
+
};
|
|
45
|
+
export type SolardTradeExecutionOptions = TradeExecutionOptions;
|
|
46
|
+
export type SolardTradeExecutionResult = TradeResult;
|
|
47
|
+
export type Solard = {
|
|
48
|
+
tx: ReturnType<typeof createCoreSolard>['tx'];
|
|
49
|
+
compileGroups: ReturnType<typeof createCoreSolard>['compileGroups'];
|
|
50
|
+
simulatePlan: ReturnType<typeof createCoreSolard>['simulatePlan'];
|
|
51
|
+
sendBatchPlans: ReturnType<typeof createCoreSolard>['sendBatchPlans'];
|
|
52
|
+
prepareFastTrade: ReturnType<typeof createCoreSolard>["prepareFastTrade"];
|
|
53
|
+
listenTrades(options?: Omit<ListenTradesOptions, "tokens"> & {
|
|
54
|
+
tokens?: readonly string[];
|
|
55
|
+
}): Promise<TradeListener>;
|
|
56
|
+
prepareUnsignedBuy: ReturnType<typeof createCoreSolard>["prepareUnsignedBuy"];
|
|
57
|
+
prepareUnsignedTokenDeployment: ReturnType<typeof createCoreSolard>["prepareUnsignedTokenDeployment"];
|
|
58
|
+
resolvePumpLaunchQuote: ReturnType<typeof createCoreSolard>["resolvePumpLaunchQuote"];
|
|
59
|
+
simulateUnsignedTokenDeployment: ReturnType<typeof createCoreSolard>["simulateUnsignedTokenDeployment"];
|
|
60
|
+
simulateUnsignedBuy: ReturnType<typeof createCoreSolard>["simulateUnsignedBuy"];
|
|
61
|
+
prepareUnsignedSell: ReturnType<typeof createCoreSolard>["prepareUnsignedSell"];
|
|
62
|
+
simulateUnsignedSell: ReturnType<typeof createCoreSolard>["simulateUnsignedSell"];
|
|
63
|
+
proposeUnsignedBuyLookupTable: ReturnType<typeof createCoreSolard>["proposeUnsignedBuyLookupTable"];
|
|
64
|
+
resolveCurrentMarket: ReturnType<typeof createCoreSolard>["resolveCurrentMarket"];
|
|
65
|
+
getClaimableCreatorFees: ReturnType<typeof createCoreSolard>["getClaimableCreatorFees"];
|
|
66
|
+
claimAllCreatorFees: ReturnType<typeof createCoreSolard>["claimAllCreatorFees"];
|
|
67
|
+
walletLedger: ReturnType<typeof createCoreSolard>["walletLedger"];
|
|
68
|
+
historicalTape: ReturnType<typeof createCoreSolard>["historicalTape"];
|
|
69
|
+
getSupportedPumpPairs: ReturnType<typeof createCoreSolard>["getSupportedPumpPairs"];
|
|
70
|
+
getSupportedLaunchLabPairs: ReturnType<typeof createCoreSolard>["getSupportedLaunchLabPairs"];
|
|
71
|
+
listVanityMints: ReturnType<typeof createCoreSolard>["listVanityMints"];
|
|
72
|
+
releaseVanityMint: ReturnType<typeof createCoreSolard>["releaseVanityMint"];
|
|
73
|
+
closeEmptyTokenAccounts: ReturnType<typeof createCoreSolard>["closeEmptyTokenAccounts"];
|
|
74
|
+
prepareTokenDeployment: ReturnType<typeof createCoreSolard>["prepareTokenDeployment"];
|
|
75
|
+
deployToken: ReturnType<typeof createCoreSolard>["deployToken"];
|
|
76
|
+
warmBlockhash: ReturnType<typeof createCoreSolard>["warmBlockhash"];
|
|
77
|
+
curveLiquidity: ReturnType<typeof createCoreSolard>["curveLiquidity"];
|
|
78
|
+
maxSendableSol: ReturnType<typeof createCoreSolard>["maxSendableSol"];
|
|
79
|
+
transferToken: ReturnType<typeof createCoreSolard>["transferToken"];
|
|
80
|
+
exitWallet: ReturnType<typeof createCoreSolard>["exitWallet"];
|
|
81
|
+
resumeTrade(intentKey: string): Promise<SolardTradeExecutionResult>;
|
|
82
|
+
reconcile(intentKey: string): Promise<SolardTradeExecutionResult>;
|
|
83
|
+
quote: ReturnType<typeof createCoreSolard>["quote"];
|
|
84
|
+
close(): void;
|
|
85
|
+
history: SolardHistoryApi;
|
|
86
|
+
events: SolardEventsApi;
|
|
87
|
+
claims: {
|
|
88
|
+
creatorFees: {
|
|
89
|
+
claim(token: TokenRef, wallet: WalletRef, options?: ClaimCreatorRewardsOptions): Promise<CreatorRewardClaimResult>;
|
|
90
|
+
status(id: string): ReturnType<ReturnType<typeof createCoreSolard>["claims"]["creatorFees"]["status"]>;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
distributions: {
|
|
94
|
+
plan(options: CumulativeDistributionInput): Promise<CumulativeDistributionPlan>;
|
|
95
|
+
execute(options: CumulativeDistributionExecuteOptions): Promise<CumulativeDistributionState>;
|
|
96
|
+
status(id: string): CumulativeDistributionState | null;
|
|
97
|
+
};
|
|
98
|
+
createWallet: ReturnType<typeof createCoreSolard>["createWallet"];
|
|
99
|
+
createVanityWallet: ReturnType<typeof createCoreSolard>["createVanityWallet"];
|
|
100
|
+
importWallet: ReturnType<typeof createCoreSolard>["importWallet"];
|
|
101
|
+
listWallets: ReturnType<typeof createCoreSolard>["listWallets"];
|
|
102
|
+
walletAddress(wallet: WalletRef): string;
|
|
103
|
+
exportPrivateKey(wallet: WalletRef, format?: WalletPrivateKeyFormat): WalletPrivateKeyExport;
|
|
104
|
+
addToken: ReturnType<typeof createCoreSolard>["addToken"];
|
|
105
|
+
resolveToken: ReturnType<typeof createCoreSolard>["resolveToken"];
|
|
106
|
+
tokenAccounts: ReturnType<typeof createCoreSolard>["tokenAccounts"];
|
|
107
|
+
snapshotHolders(token: TokenRef, options?: Omit<TokenHolderSnapshotOptions, "token">): Promise<TokenHolderSnapshot>;
|
|
108
|
+
walletBalances: ReturnType<typeof createCoreSolard>["walletBalances"];
|
|
109
|
+
recordConfirmedTrade(input: RecordConfirmedTradeInput): Promise<SolardTrade>;
|
|
110
|
+
trades(options?: SolardTradeQuery): Promise<SolardTrade[]>;
|
|
111
|
+
position(options: SolardPositionQuery): Promise<SolardPosition>;
|
|
112
|
+
getTransaction(signature: string, options?: SolardTransactionOptions): Promise<SolardDecodedTransaction | null>;
|
|
113
|
+
samplePrice(token: TokenRef): Promise<MarketPrice>;
|
|
114
|
+
buy(input: SolardBuyInput, options?: SolardTradeExecutionOptions): Promise<SolardTradeExecutionResult>;
|
|
115
|
+
sell(input: SolardSellInput, options?: SolardTradeExecutionOptions): Promise<SolardTradeExecutionResult>;
|
|
116
|
+
};
|
|
117
|
+
export declare function createSolard(options?: SolardOptions): Solard;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getSolUsdPrice } from "@solard/core";
|
|
2
|
+
import { subscribeLaunches, subscribeMigrations } from "./live.js";
|
|
3
|
+
import { type Solard } from "./client.js";
|
|
4
|
+
type DefaultSolard = Solard & {
|
|
5
|
+
getSolUsdPrice: typeof getSolUsdPrice;
|
|
6
|
+
subscribeLaunches: typeof subscribeLaunches;
|
|
7
|
+
subscribeMigrations: typeof subscribeMigrations;
|
|
8
|
+
};
|
|
9
|
+
declare const slrd: DefaultSolard;
|
|
10
|
+
export default slrd;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default } from "./default.js";
|
|
2
|
+
export { createSolard } from "./client.js";
|
|
3
|
+
export { observeSolardRpc, withSolardRpcContext } from '@solard/core';
|
|
4
|
+
export type { SolardRpcObservation, SolardRpcContext } from '@solard/core';
|
|
5
|
+
export { createTraderSolard } from "@solard/core";
|
|
6
|
+
export { normalizeValueBandPolicy, planValueBandDecision, valueBandThresholds, normalizeTargetWeightPolicy, planTargetWeightRebalance, buildHistoricalCandles, runHistoricalStrategy, sweepHistoricalStrategies, LAUNCHLAB_PLATFORM_PRESETS, resolveLaunchLabPlatform, } from "@solard/core";
|
|
7
|
+
export type { SellEconomics, SupportedLaunchLabPair, ValueBandPolicy, ValueBandRuntimeState, ValueBandDecision, TargetWeightPolicy, TargetWeightRebalancePlan, HistoricalTradeTape, HistoricalCandle, HistoricalStrategy, HistoricalExecutionOptions, HistoricalStrategyResult, CreatorFeeDiscovery, CreatorFeeGroup, CreatorFeeItem, WalletLedger, WalletLedgerEntry, WalletLedgerOptions, CurrentMarket, PreparedTokenDeployment, PrepareDeploymentArgs, } from "@solard/core";
|
|
8
|
+
export type { Solard, SolardBuyInput, SolardEventsApi, SolardHistoryApi, SolardOptions, SolardSellInput, SolardTradeExecutionOptions, SolardTradeExecutionResult, } from "./client.js";
|
|
9
|
+
export { formatRaw, sol, tokenAmount, isDefinitivePreSubmissionError, } from "@solard/core";
|
|
10
|
+
export type { ClaimCreatorRewardsOptions, TradeLandingPolicy, LivePoolReserves, CreatorRewardClaimPayout, CreatorRewardClaimResult, CumulativeDistributionExecuteOptions, CumulativeDistributionInput, CumulativeDistributionPlan, CumulativeDistributionRecipient, CumulativeDistributionState, CumulativeEntitlement, HumanAmount, MarketHistory, MarketHistoryOptions, MarketPrice, MergedReplayEventStream, QuoteAsset, ReplayCoverage, ReplayEventSubscription, ReplayEventsOptions, ReplayHistory, ReplayItem, ReplayOptions, ReplayPayout, ReplayTransaction, RecordConfirmedTradeInput, SendReceipt, SenderId, SimulationResult, SolardDecodedTransaction, SolardPosition, SolardPositionQuery, SolardTransactionNativeBalance, SolardTransactionOptions, SolardTransactionTokenBalance, SolardTrade, SolardTradeQuery, SolardTradeSide, SolardTradeStatus, SolardCanonicalEvent, SolardClaimAttribution, SolardClaimEvent, TokenEventHistoryProgress, TokenHolder, ExcludedTokenHolder, TokenHolderSnapshot, TokenHolderSnapshotOptions, TokenRef, TokenRow, WalletInfo, WalletPrivateKeyExport, WalletPrivateKeyFormat, WalletRef, } from "@solard/core";
|
|
11
|
+
export { fetchTokenMetadata, getSolUsdPrice, publicTokenMetadataUrl, } from "@solard/core";
|
|
12
|
+
export { listenTrades, subscribeLaunches, subscribeMigrations, } from "./live.js";
|
|
13
|
+
export type { ListenTradesOptions, LiveEndpointOptions, FeedRecoveryVerification, RecoverableTradeSubscription, SubscribeLaunchesOptions, SubscribeMigrationsOptions, TradeListener, TradeListenerMigration, } from "./live.js";
|
|
14
|
+
export type { LaunchEvent, LaunchSubscription, LaunchVenue, MigrationDestination, MigrationEvent, MigrationSubscription, MigrationVenue, GetSolUsdPriceOptions, SolUsdPrice, SolUsdSource, TradeEvent, TradeMarket, TradeSide, TradeVenue, FetchTokenMetadataOptions, TokenMetadata, TokenMetadataHint, TokenMetadataKind, TokenMetadataMode, } from "@solard/core";
|
|
15
|
+
export { composeTransactionDrafts } from '@solard/core';
|
|
16
|
+
export type { TransactionDraft, TransactionGroupInput, PlannedTransaction } from '@solard/core';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Connection } from "@solana/web3.js";
|
|
2
|
+
import { subscribeLaunches as subscribeCoreLaunches, subscribeMigrations as subscribeCoreMigrations, subscribeTrades as subscribeCoreTrades, type TradeEvent, type TradeSubscription, type MigrationEvent, type LiveTradeHistoryOptions } from "@solard/core";
|
|
3
|
+
export type LiveEndpointOptions = {
|
|
4
|
+
/** Ordered endpoints on the same cluster; public RPC can be supplied last. */
|
|
5
|
+
rpcUrls?: readonly string[];
|
|
6
|
+
websocketUrls?: readonly string[];
|
|
7
|
+
/** Fresh HTTP and WebSocket readiness probes for pooled trade streams (default 30s). */
|
|
8
|
+
healthCheckIntervalMs?: number;
|
|
9
|
+
};
|
|
10
|
+
export type SubscribeLaunchesOptions = Omit<Parameters<typeof subscribeCoreLaunches>[0], "connection"> & LiveEndpointOptions;
|
|
11
|
+
export type SubscribeMigrationsOptions = Omit<Parameters<typeof subscribeCoreMigrations>[0], "connection"> & LiveEndpointOptions;
|
|
12
|
+
/** Applications must explicitly revalidate fresh on-chain pool/mint state.
|
|
13
|
+
* Returning true asserts current state only, not historical coverage. */
|
|
14
|
+
export type FeedRecoveryVerification = (input: {
|
|
15
|
+
connection: Connection;
|
|
16
|
+
tokens: readonly string[];
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
}) => Promise<boolean>;
|
|
19
|
+
export type RecoverableTradeSubscription = TradeSubscription & {
|
|
20
|
+
readonly feedVerified: boolean;
|
|
21
|
+
verifyAndResume(verify: FeedRecoveryVerification, timeoutMs?: number): Promise<boolean>;
|
|
22
|
+
};
|
|
23
|
+
export type SubscribeTradesOptions = Omit<Parameters<typeof subscribeCoreTrades>[0], "connection"> & LiveEndpointOptions;
|
|
24
|
+
export type ListenTradesOptions = Omit<SubscribeTradesOptions, "onTrade"> & {
|
|
25
|
+
dbPath?: string;
|
|
26
|
+
/** Enabled by default; collected live history is partial and retains commitment. */
|
|
27
|
+
history?: false | Pick<LiveTradeHistoryOptions, "flushIntervalMs" | "batchSize" | "maxPending">;
|
|
28
|
+
};
|
|
29
|
+
export type TradeListener = {
|
|
30
|
+
add(tokens: string | readonly string[]): Promise<void>;
|
|
31
|
+
remove(tokens: string | readonly string[]): Promise<void>;
|
|
32
|
+
has(token: string): boolean;
|
|
33
|
+
list(): string[];
|
|
34
|
+
onTrade(callback: (event: TradeEvent) => void | Promise<void>): () => void;
|
|
35
|
+
onMigration(callback: (event: TradeListenerMigration) => void | Promise<void>): () => void;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
readonly closed: Promise<void>;
|
|
38
|
+
readonly feedVerified: boolean;
|
|
39
|
+
verifyAndResume(verify: FeedRecoveryVerification, timeoutMs?: number): Promise<boolean>;
|
|
40
|
+
};
|
|
41
|
+
export type TradeListenerMigration = MigrationEvent & {
|
|
42
|
+
oldPool: string | null;
|
|
43
|
+
newPool: string;
|
|
44
|
+
};
|
|
45
|
+
/** HTTP + a fresh WebSocket handshake must both succeed before choosing an endpoint. */
|
|
46
|
+
export declare class LiveEndpointPool {
|
|
47
|
+
private readonly probe;
|
|
48
|
+
private active;
|
|
49
|
+
readonly endpoints: readonly string[];
|
|
50
|
+
constructor(endpoints: readonly string[], probe?: (endpoint: string) => Promise<void>);
|
|
51
|
+
get endpoint(): string;
|
|
52
|
+
select(skipCurrent?: boolean): Promise<string>;
|
|
53
|
+
check(): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
export declare function deriveWebSocketEndpoint(endpoint: string): string;
|
|
56
|
+
export declare function redactRpcEndpoint(endpoint: string): string;
|
|
57
|
+
export declare function subscribeTrades(options: SubscribeTradesOptions): Promise<RecoverableTradeSubscription>;
|
|
58
|
+
export declare function subscribeLaunches(options: SubscribeLaunchesOptions): Promise<import("@solard/core").LaunchSubscription>;
|
|
59
|
+
export declare function subscribeMigrations(options: SubscribeMigrationsOptions): Promise<import("@solard/core").MigrationSubscription>;
|
|
60
|
+
export declare function listenTrades(options: ListenTradesOptions): Promise<TradeListener>;
|
package/package.json
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solard/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.40",
|
|
4
4
|
"description": "Public Solard SDK for wallets, trading, history, live market subscriptions and token metadata.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"module": "./src/index.ts",
|
|
8
|
-
"types": "./
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./src/index.ts",
|
|
13
|
+
"default": "./src/index.ts"
|
|
14
|
+
},
|
|
11
15
|
"./browser": {
|
|
12
|
-
"types": "./
|
|
16
|
+
"types": "./dist/types/browser/index.d.ts",
|
|
13
17
|
"import": "./src/browser/index.ts",
|
|
14
18
|
"default": "./src/browser/index.ts"
|
|
15
19
|
},
|
|
16
20
|
"./protocol": {
|
|
17
|
-
"types": "./
|
|
21
|
+
"types": "./dist/types/protocol.d.ts",
|
|
18
22
|
"import": "./src/protocol.ts",
|
|
19
23
|
"default": "./src/protocol.ts"
|
|
20
24
|
}
|
|
@@ -22,15 +26,17 @@
|
|
|
22
26
|
"files": [
|
|
23
27
|
"src",
|
|
24
28
|
"README.md",
|
|
25
|
-
"LICENSE"
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"dist/types"
|
|
26
31
|
],
|
|
27
32
|
"license": "MIT",
|
|
28
33
|
"dependencies": {
|
|
29
34
|
"@solana/web3.js": "^1.98.4",
|
|
30
|
-
"@solard/core": "0.2.
|
|
35
|
+
"@solard/core": "0.2.40"
|
|
31
36
|
},
|
|
32
37
|
"scripts": {
|
|
33
38
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json",
|
|
34
|
-
"typecheck:browser": "tsc --noEmit -p tsconfig.browser.json"
|
|
39
|
+
"typecheck:browser": "tsc --noEmit -p tsconfig.browser.json",
|
|
40
|
+
"prepack": "bun run ../../scripts/build-declarations.mjs"
|
|
35
41
|
}
|
|
36
42
|
}
|