@atomiqlabs/chain-solana 13.5.13 → 13.5.14
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/LICENSE +201 -201
- package/README.md +73 -73
- package/dist/index.d.ts +81 -81
- package/dist/index.js +102 -102
- package/dist/node/index.d.ts +9 -9
- package/dist/node/index.js +13 -13
- package/dist/solana/SolanaChainType.d.ts +15 -15
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +12 -12
- package/dist/solana/SolanaChains.js +45 -45
- package/dist/solana/SolanaInitializer.d.ts +94 -94
- package/dist/solana/SolanaInitializer.js +174 -174
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +222 -222
- package/dist/solana/btcrelay/SolanaBtcRelay.js +455 -455
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +84 -84
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +70 -70
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +92 -92
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +109 -109
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +87 -87
- package/dist/solana/chain/SolanaChainInterface.d.ts +224 -224
- package/dist/solana/chain/SolanaChainInterface.js +275 -275
- package/dist/solana/chain/SolanaModule.d.ts +14 -14
- package/dist/solana/chain/SolanaModule.js +13 -13
- package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
- package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
- package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -32
- package/dist/solana/chain/modules/SolanaBlocks.js +78 -78
- package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
- package/dist/solana/chain/modules/SolanaEvents.js +238 -238
- package/dist/solana/chain/modules/SolanaFees.d.ts +189 -189
- package/dist/solana/chain/modules/SolanaFees.js +434 -434
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -24
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +33 -33
- package/dist/solana/chain/modules/SolanaSlots.js +72 -72
- package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -123
- package/dist/solana/chain/modules/SolanaTokens.js +242 -242
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +149 -149
- package/dist/solana/chain/modules/SolanaTransactions.js +445 -445
- package/dist/solana/connection/ConnectionWithRetries.d.ts +35 -35
- package/dist/solana/connection/ConnectionWithRetries.js +86 -71
- package/dist/solana/events/SolanaChainEvents.d.ts +45 -45
- package/dist/solana/events/SolanaChainEvents.js +108 -108
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +205 -205
- package/dist/solana/events/SolanaChainEventsBrowser.js +404 -404
- package/dist/solana/program/SolanaProgramBase.d.ts +73 -73
- package/dist/solana/program/SolanaProgramBase.js +54 -54
- package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
- package/dist/solana/program/SolanaProgramModule.js +11 -11
- package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
- package/dist/solana/program/modules/SolanaProgramEvents.js +117 -117
- package/dist/solana/swaps/SolanaSwapData.d.ts +333 -333
- package/dist/solana/swaps/SolanaSwapData.js +535 -535
- package/dist/solana/swaps/SolanaSwapModule.d.ts +11 -11
- package/dist/solana/swaps/SolanaSwapModule.js +12 -12
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +376 -376
- package/dist/solana/swaps/SolanaSwapProgram.js +769 -769
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +43 -43
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -95
- package/dist/solana/swaps/modules/SolanaDataAccount.js +232 -232
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -69
- package/dist/solana/swaps/modules/SolanaLpVault.js +171 -171
- package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -126
- package/dist/solana/swaps/modules/SwapClaim.js +294 -294
- package/dist/solana/swaps/modules/SwapInit.d.ts +213 -213
- package/dist/solana/swaps/modules/SwapInit.js +658 -658
- package/dist/solana/swaps/modules/SwapRefund.d.ts +87 -87
- package/dist/solana/swaps/modules/SwapRefund.js +293 -293
- package/dist/solana/swaps/programIdl.json +945 -945
- package/dist/solana/swaps/programTypes.d.ts +943 -943
- package/dist/solana/swaps/programTypes.js +945 -945
- package/dist/solana/swaps/v1/programIdl.json +945 -945
- package/dist/solana/swaps/v1/programTypes.d.ts +943 -943
- package/dist/solana/swaps/v1/programTypes.js +945 -945
- package/dist/solana/swaps/v2/programIdl.json +952 -952
- package/dist/solana/swaps/v2/programTypes.d.ts +950 -950
- package/dist/solana/swaps/v2/programTypes.js +952 -952
- package/dist/solana/wallet/SolanaKeypairWallet.d.ts +29 -29
- package/dist/solana/wallet/SolanaKeypairWallet.js +50 -50
- package/dist/solana/wallet/SolanaSigner.d.ts +30 -30
- package/dist/solana/wallet/SolanaSigner.js +30 -30
- package/dist/utils/Utils.d.ts +58 -58
- package/dist/utils/Utils.js +170 -170
- package/node/index.d.ts +1 -1
- package/node/index.js +3 -3
- package/package.json +46 -46
- package/src/index.ts +87 -87
- package/src/node/index.ts +9 -9
- package/src/solana/SolanaChainType.ts +32 -32
- package/src/solana/SolanaChains.ts +46 -46
- package/src/solana/SolanaInitializer.ts +278 -278
- package/src/solana/btcrelay/SolanaBtcRelay.ts +615 -615
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +116 -116
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +148 -148
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +109 -109
- package/src/solana/chain/SolanaChainInterface.ts +404 -404
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +89 -89
- package/src/solana/chain/modules/SolanaEvents.ts +271 -271
- package/src/solana/chain/modules/SolanaFees.ts +522 -522
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +85 -85
- package/src/solana/chain/modules/SolanaTokens.ts +300 -300
- package/src/solana/chain/modules/SolanaTransactions.ts +503 -503
- package/src/solana/connection/ConnectionWithRetries.ts +113 -96
- package/src/solana/events/SolanaChainEvents.ts +127 -127
- package/src/solana/events/SolanaChainEventsBrowser.ts +495 -495
- package/src/solana/program/SolanaProgramBase.ts +119 -119
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +157 -157
- package/src/solana/swaps/SolanaSwapData.ts +735 -735
- package/src/solana/swaps/SolanaSwapModule.ts +19 -19
- package/src/solana/swaps/SolanaSwapProgram.ts +1074 -1074
- package/src/solana/swaps/SwapTypeEnum.ts +30 -30
- package/src/solana/swaps/modules/SolanaDataAccount.ts +302 -302
- package/src/solana/swaps/modules/SolanaLpVault.ts +208 -208
- package/src/solana/swaps/modules/SwapClaim.ts +387 -387
- package/src/solana/swaps/modules/SwapInit.ts +785 -785
- package/src/solana/swaps/modules/SwapRefund.ts +353 -353
- package/src/solana/swaps/v1/programIdl.json +944 -944
- package/src/solana/swaps/v1/programTypes.ts +1885 -1885
- package/src/solana/swaps/v2/programIdl.json +951 -951
- package/src/solana/swaps/v2/programTypes.ts +1899 -1899
- package/src/solana/wallet/SolanaKeypairWallet.ts +56 -56
- package/src/solana/wallet/SolanaSigner.ts +43 -43
- package/src/utils/Utils.ts +194 -194
|
@@ -1,333 +1,333 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import * as BN from "bn.js";
|
|
3
|
-
import { ChainSwapType, SwapData } from "@atomiqlabs/base";
|
|
4
|
-
import { SwapProgram } from "./v1/programTypes";
|
|
5
|
-
import { IdlAccounts, IdlTypes } from "@coral-xyz/anchor";
|
|
6
|
-
import { Serialized } from "../../utils/Utils";
|
|
7
|
-
import { SingleInstructionWithAccounts } from "../program/modules/SolanaProgramEvents";
|
|
8
|
-
import { SwapProgramV2 } from "./v2/programTypes";
|
|
9
|
-
export type InitInstruction = SingleInstructionWithAccounts<SwapProgram["instructions"][2 | 3] | SwapProgramV2["instructions"][2 | 3], SwapProgram>;
|
|
10
|
-
export type SolanaSwapDataCtorArgs = {
|
|
11
|
-
programId: PublicKey;
|
|
12
|
-
version: "v1" | "v2";
|
|
13
|
-
offerer: PublicKey;
|
|
14
|
-
claimer: PublicKey;
|
|
15
|
-
token: PublicKey;
|
|
16
|
-
amount: BN;
|
|
17
|
-
paymentHash: string;
|
|
18
|
-
sequence: BN;
|
|
19
|
-
expiry: BN;
|
|
20
|
-
nonce: BN;
|
|
21
|
-
confirmations: number;
|
|
22
|
-
payOut: boolean;
|
|
23
|
-
kind: number;
|
|
24
|
-
payIn: boolean;
|
|
25
|
-
offererAta?: PublicKey;
|
|
26
|
-
claimerAta?: PublicKey;
|
|
27
|
-
securityDeposit: BN;
|
|
28
|
-
claimerBounty: BN;
|
|
29
|
-
txoHash?: string;
|
|
30
|
-
offererInitializer?: boolean;
|
|
31
|
-
};
|
|
32
|
-
export declare function isSerializedData(obj: any): obj is ({
|
|
33
|
-
type: "sol";
|
|
34
|
-
} & Serialized<SolanaSwapData>);
|
|
35
|
-
/**
|
|
36
|
-
* Represents Solana swap data for executing PrTLC (on-chain) or HTLC (lightning) based swaps.
|
|
37
|
-
*
|
|
38
|
-
* @category Swaps
|
|
39
|
-
*/
|
|
40
|
-
export declare class SolanaSwapData extends SwapData {
|
|
41
|
-
/**
|
|
42
|
-
* Program ID for which this swap data was created
|
|
43
|
-
*/
|
|
44
|
-
programId: PublicKey;
|
|
45
|
-
/**
|
|
46
|
-
* Program version for which this swap was created
|
|
47
|
-
*/
|
|
48
|
-
version: "v1" | "v2";
|
|
49
|
-
/**
|
|
50
|
-
* Offerer address funding the swap.
|
|
51
|
-
*/
|
|
52
|
-
offerer: PublicKey;
|
|
53
|
-
/**
|
|
54
|
-
* Claimer address receiving the swap funds.
|
|
55
|
-
*/
|
|
56
|
-
claimer: PublicKey;
|
|
57
|
-
/**
|
|
58
|
-
* Token mint used for the swap.
|
|
59
|
-
*/
|
|
60
|
-
token: PublicKey;
|
|
61
|
-
/**
|
|
62
|
-
* Swap amount.
|
|
63
|
-
*/
|
|
64
|
-
amount: BN;
|
|
65
|
-
/**
|
|
66
|
-
* Payment hash identifying the swap.
|
|
67
|
-
*/
|
|
68
|
-
paymentHash: string;
|
|
69
|
-
/**
|
|
70
|
-
* Swap sequence used for uniqueness.
|
|
71
|
-
*/
|
|
72
|
-
sequence: BN;
|
|
73
|
-
/**
|
|
74
|
-
* Swap expiry timestamp.
|
|
75
|
-
*/
|
|
76
|
-
expiry: BN;
|
|
77
|
-
/**
|
|
78
|
-
* Nonce used in claim hash derivation.
|
|
79
|
-
*/
|
|
80
|
-
nonce: BN;
|
|
81
|
-
/**
|
|
82
|
-
* Required bitcoin confirmations for claim.
|
|
83
|
-
*/
|
|
84
|
-
confirmations: number;
|
|
85
|
-
/**
|
|
86
|
-
* Whether funds are paid out to claimer wallet directly.
|
|
87
|
-
*/
|
|
88
|
-
payOut: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Solana on-chain swap kind discriminator.
|
|
91
|
-
*/
|
|
92
|
-
kind: number;
|
|
93
|
-
/**
|
|
94
|
-
* Whether funds are paid in from offerer wallet.
|
|
95
|
-
*/
|
|
96
|
-
payIn: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Optional claimer associated token account.
|
|
99
|
-
*/
|
|
100
|
-
claimerAta?: PublicKey;
|
|
101
|
-
/**
|
|
102
|
-
* Optional offerer associated token account.
|
|
103
|
-
*/
|
|
104
|
-
offererAta?: PublicKey;
|
|
105
|
-
/**
|
|
106
|
-
* Security deposit amount.
|
|
107
|
-
*/
|
|
108
|
-
securityDeposit: BN;
|
|
109
|
-
/**
|
|
110
|
-
* Claimer bounty amount.
|
|
111
|
-
*/
|
|
112
|
-
claimerBounty: BN;
|
|
113
|
-
/**
|
|
114
|
-
* Optional txo hash hint.
|
|
115
|
-
*/
|
|
116
|
-
txoHash?: string;
|
|
117
|
-
/**
|
|
118
|
-
* Optional flag whether the offerer is the initializer for V2 swap data
|
|
119
|
-
*/
|
|
120
|
-
offererInitializer?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Creates swap data from structured constructor arguments.
|
|
123
|
-
*
|
|
124
|
-
* @param args Swap data fields
|
|
125
|
-
*/
|
|
126
|
-
constructor(args: SolanaSwapDataCtorArgs);
|
|
127
|
-
/**
|
|
128
|
-
* Deserializes swap data from serialized storage representation.
|
|
129
|
-
*
|
|
130
|
-
* @param data Serialized swap data from {@link SolanaSwapData.serialize}
|
|
131
|
-
*/
|
|
132
|
-
constructor(data: {
|
|
133
|
-
type: "sol";
|
|
134
|
-
} & Serialized<SolanaSwapData>);
|
|
135
|
-
/**
|
|
136
|
-
* @inheritDoc
|
|
137
|
-
*/
|
|
138
|
-
getOfferer(): string;
|
|
139
|
-
/**
|
|
140
|
-
* @inheritDoc
|
|
141
|
-
*/
|
|
142
|
-
setOfferer(newOfferer: string): void;
|
|
143
|
-
/**
|
|
144
|
-
* @inheritDoc
|
|
145
|
-
*/
|
|
146
|
-
getClaimer(): string;
|
|
147
|
-
/**
|
|
148
|
-
* @inheritDoc
|
|
149
|
-
*/
|
|
150
|
-
setClaimer(newClaimer: string): void;
|
|
151
|
-
/**
|
|
152
|
-
* @inheritDoc
|
|
153
|
-
*/
|
|
154
|
-
serialize(): {
|
|
155
|
-
type: "sol";
|
|
156
|
-
} & Serialized<SolanaSwapData>;
|
|
157
|
-
/**
|
|
158
|
-
* @inheritDoc
|
|
159
|
-
*/
|
|
160
|
-
getAmount(): bigint;
|
|
161
|
-
/**
|
|
162
|
-
* @inheritDoc
|
|
163
|
-
*/
|
|
164
|
-
getToken(): string;
|
|
165
|
-
/**
|
|
166
|
-
* @inheritDoc
|
|
167
|
-
*/
|
|
168
|
-
isToken(token: string): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* @inheritDoc
|
|
171
|
-
*/
|
|
172
|
-
getType(): ChainSwapType;
|
|
173
|
-
/**
|
|
174
|
-
* @inheritDoc
|
|
175
|
-
*/
|
|
176
|
-
getExpiry(): bigint;
|
|
177
|
-
/**
|
|
178
|
-
* @inheritDoc
|
|
179
|
-
*/
|
|
180
|
-
getConfirmationsHint(): number;
|
|
181
|
-
/**
|
|
182
|
-
* @inheritDoc
|
|
183
|
-
*/
|
|
184
|
-
getNonceHint(): bigint;
|
|
185
|
-
/**
|
|
186
|
-
* @inheritDoc
|
|
187
|
-
*/
|
|
188
|
-
isPayIn(): boolean;
|
|
189
|
-
/**
|
|
190
|
-
* @inheritDoc
|
|
191
|
-
*/
|
|
192
|
-
isPayOut(): boolean;
|
|
193
|
-
/**
|
|
194
|
-
* @inheritDoc
|
|
195
|
-
*/
|
|
196
|
-
isTrackingReputation(): boolean;
|
|
197
|
-
/**
|
|
198
|
-
* @inheritDoc
|
|
199
|
-
*/
|
|
200
|
-
getClaimHash(): string;
|
|
201
|
-
/**
|
|
202
|
-
* @inheritDoc
|
|
203
|
-
*/
|
|
204
|
-
getEscrowHash(): string;
|
|
205
|
-
/**
|
|
206
|
-
* @inheritDoc
|
|
207
|
-
*/
|
|
208
|
-
getSequence(): bigint;
|
|
209
|
-
/**
|
|
210
|
-
* @inheritDoc
|
|
211
|
-
*/
|
|
212
|
-
getTxoHashHint(): string | null;
|
|
213
|
-
/**
|
|
214
|
-
* @inheritDoc
|
|
215
|
-
*/
|
|
216
|
-
getHTLCHashHint(): string | null;
|
|
217
|
-
/**
|
|
218
|
-
* @inheritDoc
|
|
219
|
-
*/
|
|
220
|
-
getExtraData(): string | null;
|
|
221
|
-
/**
|
|
222
|
-
* @inheritDoc
|
|
223
|
-
*/
|
|
224
|
-
setExtraData(txoHash: string): void;
|
|
225
|
-
/**
|
|
226
|
-
* @inheritDoc
|
|
227
|
-
*/
|
|
228
|
-
getSecurityDeposit(): bigint;
|
|
229
|
-
/**
|
|
230
|
-
* @inheritDoc
|
|
231
|
-
*/
|
|
232
|
-
getClaimerBounty(): bigint;
|
|
233
|
-
/**
|
|
234
|
-
* @inheritDoc
|
|
235
|
-
*/
|
|
236
|
-
getTotalDeposit(): bigint;
|
|
237
|
-
/**
|
|
238
|
-
* Serializes the swap data into the Solana program `SwapData` struct representation.
|
|
239
|
-
*/
|
|
240
|
-
toSwapDataStruct(): IdlTypes<SwapProgram>["SwapData"];
|
|
241
|
-
/**
|
|
242
|
-
* Checks whether the provided escrow account matches this swap data.
|
|
243
|
-
*
|
|
244
|
-
* @param account Escrow account data fetched from chain
|
|
245
|
-
*/
|
|
246
|
-
correctPDA(account: IdlAccounts<SwapProgram | SwapProgramV2>["escrowState"]): boolean;
|
|
247
|
-
/**
|
|
248
|
-
* @inheritDoc
|
|
249
|
-
*/
|
|
250
|
-
equals(other: SolanaSwapData): boolean;
|
|
251
|
-
/**
|
|
252
|
-
* Converts initialize instruction data into {@link SolanaSwapData}.
|
|
253
|
-
*
|
|
254
|
-
* @param programId
|
|
255
|
-
* @param version
|
|
256
|
-
* @param initIx Decoded initialize instruction
|
|
257
|
-
* @param txoHash Parsed txo hash hint from initialize event
|
|
258
|
-
* @returns Converted and parsed swap data
|
|
259
|
-
*/
|
|
260
|
-
static fromInstruction(programId: PublicKey, version: "v1" | "v2", initIx: InitInstruction, txoHash: string): SolanaSwapData;
|
|
261
|
-
/**
|
|
262
|
-
* Deserializes swap data from an on-chain escrow account state.
|
|
263
|
-
*
|
|
264
|
-
* @param programId
|
|
265
|
-
* @param version
|
|
266
|
-
* @param account Escrow account state as returned by Anchor
|
|
267
|
-
*/
|
|
268
|
-
static fromEscrowState(programId: PublicKey, version: "v1" | "v2", account: IdlAccounts<SwapProgram | SwapProgramV2>["escrowState"]): SolanaSwapData;
|
|
269
|
-
/**
|
|
270
|
-
* Converts abstract swap type to Solana program kind discriminator.
|
|
271
|
-
*
|
|
272
|
-
* @param type Chain-agnostic swap type
|
|
273
|
-
*/
|
|
274
|
-
static typeToKind(type: ChainSwapType): number;
|
|
275
|
-
/**
|
|
276
|
-
* Converts Solana program kind discriminator to abstract swap type.
|
|
277
|
-
*
|
|
278
|
-
* @param value Solana program swap kind value
|
|
279
|
-
*/
|
|
280
|
-
static kindToType(value: number): ChainSwapType;
|
|
281
|
-
/**
|
|
282
|
-
* @inheritDoc
|
|
283
|
-
*/
|
|
284
|
-
isClaimer(address: string): boolean;
|
|
285
|
-
/**
|
|
286
|
-
* @inheritDoc
|
|
287
|
-
*/
|
|
288
|
-
isOfferer(address: string): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* @inheritDoc
|
|
291
|
-
*/
|
|
292
|
-
getDepositToken(): string;
|
|
293
|
-
/**
|
|
294
|
-
* @inheritDoc
|
|
295
|
-
*/
|
|
296
|
-
isDepositToken(token: string): boolean;
|
|
297
|
-
/**
|
|
298
|
-
* @inheritDoc
|
|
299
|
-
*/
|
|
300
|
-
getEscrowStruct(): any;
|
|
301
|
-
}
|
|
302
|
-
export declare class SolanaSwapDataV1 extends SolanaSwapData {
|
|
303
|
-
/**
|
|
304
|
-
* Creates swap data from structured constructor arguments.
|
|
305
|
-
*
|
|
306
|
-
* @param args Swap data fields
|
|
307
|
-
*/
|
|
308
|
-
constructor(args: SolanaSwapDataCtorArgs);
|
|
309
|
-
/**
|
|
310
|
-
* Deserializes swap data from serialized storage representation.
|
|
311
|
-
*
|
|
312
|
-
* @param data Serialized swap data from {@link SolanaSwapData.serialize}
|
|
313
|
-
*/
|
|
314
|
-
constructor(data: {
|
|
315
|
-
type: "sol";
|
|
316
|
-
} & Serialized<SolanaSwapData>);
|
|
317
|
-
}
|
|
318
|
-
export declare class SolanaSwapDataV2 extends SolanaSwapData {
|
|
319
|
-
/**
|
|
320
|
-
* Creates swap data from structured constructor arguments.
|
|
321
|
-
*
|
|
322
|
-
* @param args Swap data fields
|
|
323
|
-
*/
|
|
324
|
-
constructor(args: SolanaSwapDataCtorArgs);
|
|
325
|
-
/**
|
|
326
|
-
* Deserializes swap data from serialized storage representation.
|
|
327
|
-
*
|
|
328
|
-
* @param data Serialized swap data from {@link SolanaSwapData.serialize}
|
|
329
|
-
*/
|
|
330
|
-
constructor(data: {
|
|
331
|
-
type: "sol";
|
|
332
|
-
} & Serialized<SolanaSwapData>);
|
|
333
|
-
}
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import * as BN from "bn.js";
|
|
3
|
+
import { ChainSwapType, SwapData } from "@atomiqlabs/base";
|
|
4
|
+
import { SwapProgram } from "./v1/programTypes";
|
|
5
|
+
import { IdlAccounts, IdlTypes } from "@coral-xyz/anchor";
|
|
6
|
+
import { Serialized } from "../../utils/Utils";
|
|
7
|
+
import { SingleInstructionWithAccounts } from "../program/modules/SolanaProgramEvents";
|
|
8
|
+
import { SwapProgramV2 } from "./v2/programTypes";
|
|
9
|
+
export type InitInstruction = SingleInstructionWithAccounts<SwapProgram["instructions"][2 | 3] | SwapProgramV2["instructions"][2 | 3], SwapProgram>;
|
|
10
|
+
export type SolanaSwapDataCtorArgs = {
|
|
11
|
+
programId: PublicKey;
|
|
12
|
+
version: "v1" | "v2";
|
|
13
|
+
offerer: PublicKey;
|
|
14
|
+
claimer: PublicKey;
|
|
15
|
+
token: PublicKey;
|
|
16
|
+
amount: BN;
|
|
17
|
+
paymentHash: string;
|
|
18
|
+
sequence: BN;
|
|
19
|
+
expiry: BN;
|
|
20
|
+
nonce: BN;
|
|
21
|
+
confirmations: number;
|
|
22
|
+
payOut: boolean;
|
|
23
|
+
kind: number;
|
|
24
|
+
payIn: boolean;
|
|
25
|
+
offererAta?: PublicKey;
|
|
26
|
+
claimerAta?: PublicKey;
|
|
27
|
+
securityDeposit: BN;
|
|
28
|
+
claimerBounty: BN;
|
|
29
|
+
txoHash?: string;
|
|
30
|
+
offererInitializer?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare function isSerializedData(obj: any): obj is ({
|
|
33
|
+
type: "sol";
|
|
34
|
+
} & Serialized<SolanaSwapData>);
|
|
35
|
+
/**
|
|
36
|
+
* Represents Solana swap data for executing PrTLC (on-chain) or HTLC (lightning) based swaps.
|
|
37
|
+
*
|
|
38
|
+
* @category Swaps
|
|
39
|
+
*/
|
|
40
|
+
export declare class SolanaSwapData extends SwapData {
|
|
41
|
+
/**
|
|
42
|
+
* Program ID for which this swap data was created
|
|
43
|
+
*/
|
|
44
|
+
programId: PublicKey;
|
|
45
|
+
/**
|
|
46
|
+
* Program version for which this swap was created
|
|
47
|
+
*/
|
|
48
|
+
version: "v1" | "v2";
|
|
49
|
+
/**
|
|
50
|
+
* Offerer address funding the swap.
|
|
51
|
+
*/
|
|
52
|
+
offerer: PublicKey;
|
|
53
|
+
/**
|
|
54
|
+
* Claimer address receiving the swap funds.
|
|
55
|
+
*/
|
|
56
|
+
claimer: PublicKey;
|
|
57
|
+
/**
|
|
58
|
+
* Token mint used for the swap.
|
|
59
|
+
*/
|
|
60
|
+
token: PublicKey;
|
|
61
|
+
/**
|
|
62
|
+
* Swap amount.
|
|
63
|
+
*/
|
|
64
|
+
amount: BN;
|
|
65
|
+
/**
|
|
66
|
+
* Payment hash identifying the swap.
|
|
67
|
+
*/
|
|
68
|
+
paymentHash: string;
|
|
69
|
+
/**
|
|
70
|
+
* Swap sequence used for uniqueness.
|
|
71
|
+
*/
|
|
72
|
+
sequence: BN;
|
|
73
|
+
/**
|
|
74
|
+
* Swap expiry timestamp.
|
|
75
|
+
*/
|
|
76
|
+
expiry: BN;
|
|
77
|
+
/**
|
|
78
|
+
* Nonce used in claim hash derivation.
|
|
79
|
+
*/
|
|
80
|
+
nonce: BN;
|
|
81
|
+
/**
|
|
82
|
+
* Required bitcoin confirmations for claim.
|
|
83
|
+
*/
|
|
84
|
+
confirmations: number;
|
|
85
|
+
/**
|
|
86
|
+
* Whether funds are paid out to claimer wallet directly.
|
|
87
|
+
*/
|
|
88
|
+
payOut: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Solana on-chain swap kind discriminator.
|
|
91
|
+
*/
|
|
92
|
+
kind: number;
|
|
93
|
+
/**
|
|
94
|
+
* Whether funds are paid in from offerer wallet.
|
|
95
|
+
*/
|
|
96
|
+
payIn: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Optional claimer associated token account.
|
|
99
|
+
*/
|
|
100
|
+
claimerAta?: PublicKey;
|
|
101
|
+
/**
|
|
102
|
+
* Optional offerer associated token account.
|
|
103
|
+
*/
|
|
104
|
+
offererAta?: PublicKey;
|
|
105
|
+
/**
|
|
106
|
+
* Security deposit amount.
|
|
107
|
+
*/
|
|
108
|
+
securityDeposit: BN;
|
|
109
|
+
/**
|
|
110
|
+
* Claimer bounty amount.
|
|
111
|
+
*/
|
|
112
|
+
claimerBounty: BN;
|
|
113
|
+
/**
|
|
114
|
+
* Optional txo hash hint.
|
|
115
|
+
*/
|
|
116
|
+
txoHash?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Optional flag whether the offerer is the initializer for V2 swap data
|
|
119
|
+
*/
|
|
120
|
+
offererInitializer?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Creates swap data from structured constructor arguments.
|
|
123
|
+
*
|
|
124
|
+
* @param args Swap data fields
|
|
125
|
+
*/
|
|
126
|
+
constructor(args: SolanaSwapDataCtorArgs);
|
|
127
|
+
/**
|
|
128
|
+
* Deserializes swap data from serialized storage representation.
|
|
129
|
+
*
|
|
130
|
+
* @param data Serialized swap data from {@link SolanaSwapData.serialize}
|
|
131
|
+
*/
|
|
132
|
+
constructor(data: {
|
|
133
|
+
type: "sol";
|
|
134
|
+
} & Serialized<SolanaSwapData>);
|
|
135
|
+
/**
|
|
136
|
+
* @inheritDoc
|
|
137
|
+
*/
|
|
138
|
+
getOfferer(): string;
|
|
139
|
+
/**
|
|
140
|
+
* @inheritDoc
|
|
141
|
+
*/
|
|
142
|
+
setOfferer(newOfferer: string): void;
|
|
143
|
+
/**
|
|
144
|
+
* @inheritDoc
|
|
145
|
+
*/
|
|
146
|
+
getClaimer(): string;
|
|
147
|
+
/**
|
|
148
|
+
* @inheritDoc
|
|
149
|
+
*/
|
|
150
|
+
setClaimer(newClaimer: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* @inheritDoc
|
|
153
|
+
*/
|
|
154
|
+
serialize(): {
|
|
155
|
+
type: "sol";
|
|
156
|
+
} & Serialized<SolanaSwapData>;
|
|
157
|
+
/**
|
|
158
|
+
* @inheritDoc
|
|
159
|
+
*/
|
|
160
|
+
getAmount(): bigint;
|
|
161
|
+
/**
|
|
162
|
+
* @inheritDoc
|
|
163
|
+
*/
|
|
164
|
+
getToken(): string;
|
|
165
|
+
/**
|
|
166
|
+
* @inheritDoc
|
|
167
|
+
*/
|
|
168
|
+
isToken(token: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* @inheritDoc
|
|
171
|
+
*/
|
|
172
|
+
getType(): ChainSwapType;
|
|
173
|
+
/**
|
|
174
|
+
* @inheritDoc
|
|
175
|
+
*/
|
|
176
|
+
getExpiry(): bigint;
|
|
177
|
+
/**
|
|
178
|
+
* @inheritDoc
|
|
179
|
+
*/
|
|
180
|
+
getConfirmationsHint(): number;
|
|
181
|
+
/**
|
|
182
|
+
* @inheritDoc
|
|
183
|
+
*/
|
|
184
|
+
getNonceHint(): bigint;
|
|
185
|
+
/**
|
|
186
|
+
* @inheritDoc
|
|
187
|
+
*/
|
|
188
|
+
isPayIn(): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* @inheritDoc
|
|
191
|
+
*/
|
|
192
|
+
isPayOut(): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* @inheritDoc
|
|
195
|
+
*/
|
|
196
|
+
isTrackingReputation(): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* @inheritDoc
|
|
199
|
+
*/
|
|
200
|
+
getClaimHash(): string;
|
|
201
|
+
/**
|
|
202
|
+
* @inheritDoc
|
|
203
|
+
*/
|
|
204
|
+
getEscrowHash(): string;
|
|
205
|
+
/**
|
|
206
|
+
* @inheritDoc
|
|
207
|
+
*/
|
|
208
|
+
getSequence(): bigint;
|
|
209
|
+
/**
|
|
210
|
+
* @inheritDoc
|
|
211
|
+
*/
|
|
212
|
+
getTxoHashHint(): string | null;
|
|
213
|
+
/**
|
|
214
|
+
* @inheritDoc
|
|
215
|
+
*/
|
|
216
|
+
getHTLCHashHint(): string | null;
|
|
217
|
+
/**
|
|
218
|
+
* @inheritDoc
|
|
219
|
+
*/
|
|
220
|
+
getExtraData(): string | null;
|
|
221
|
+
/**
|
|
222
|
+
* @inheritDoc
|
|
223
|
+
*/
|
|
224
|
+
setExtraData(txoHash: string): void;
|
|
225
|
+
/**
|
|
226
|
+
* @inheritDoc
|
|
227
|
+
*/
|
|
228
|
+
getSecurityDeposit(): bigint;
|
|
229
|
+
/**
|
|
230
|
+
* @inheritDoc
|
|
231
|
+
*/
|
|
232
|
+
getClaimerBounty(): bigint;
|
|
233
|
+
/**
|
|
234
|
+
* @inheritDoc
|
|
235
|
+
*/
|
|
236
|
+
getTotalDeposit(): bigint;
|
|
237
|
+
/**
|
|
238
|
+
* Serializes the swap data into the Solana program `SwapData` struct representation.
|
|
239
|
+
*/
|
|
240
|
+
toSwapDataStruct(): IdlTypes<SwapProgram>["SwapData"];
|
|
241
|
+
/**
|
|
242
|
+
* Checks whether the provided escrow account matches this swap data.
|
|
243
|
+
*
|
|
244
|
+
* @param account Escrow account data fetched from chain
|
|
245
|
+
*/
|
|
246
|
+
correctPDA(account: IdlAccounts<SwapProgram | SwapProgramV2>["escrowState"]): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* @inheritDoc
|
|
249
|
+
*/
|
|
250
|
+
equals(other: SolanaSwapData): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Converts initialize instruction data into {@link SolanaSwapData}.
|
|
253
|
+
*
|
|
254
|
+
* @param programId
|
|
255
|
+
* @param version
|
|
256
|
+
* @param initIx Decoded initialize instruction
|
|
257
|
+
* @param txoHash Parsed txo hash hint from initialize event
|
|
258
|
+
* @returns Converted and parsed swap data
|
|
259
|
+
*/
|
|
260
|
+
static fromInstruction(programId: PublicKey, version: "v1" | "v2", initIx: InitInstruction, txoHash: string): SolanaSwapData;
|
|
261
|
+
/**
|
|
262
|
+
* Deserializes swap data from an on-chain escrow account state.
|
|
263
|
+
*
|
|
264
|
+
* @param programId
|
|
265
|
+
* @param version
|
|
266
|
+
* @param account Escrow account state as returned by Anchor
|
|
267
|
+
*/
|
|
268
|
+
static fromEscrowState(programId: PublicKey, version: "v1" | "v2", account: IdlAccounts<SwapProgram | SwapProgramV2>["escrowState"]): SolanaSwapData;
|
|
269
|
+
/**
|
|
270
|
+
* Converts abstract swap type to Solana program kind discriminator.
|
|
271
|
+
*
|
|
272
|
+
* @param type Chain-agnostic swap type
|
|
273
|
+
*/
|
|
274
|
+
static typeToKind(type: ChainSwapType): number;
|
|
275
|
+
/**
|
|
276
|
+
* Converts Solana program kind discriminator to abstract swap type.
|
|
277
|
+
*
|
|
278
|
+
* @param value Solana program swap kind value
|
|
279
|
+
*/
|
|
280
|
+
static kindToType(value: number): ChainSwapType;
|
|
281
|
+
/**
|
|
282
|
+
* @inheritDoc
|
|
283
|
+
*/
|
|
284
|
+
isClaimer(address: string): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* @inheritDoc
|
|
287
|
+
*/
|
|
288
|
+
isOfferer(address: string): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* @inheritDoc
|
|
291
|
+
*/
|
|
292
|
+
getDepositToken(): string;
|
|
293
|
+
/**
|
|
294
|
+
* @inheritDoc
|
|
295
|
+
*/
|
|
296
|
+
isDepositToken(token: string): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* @inheritDoc
|
|
299
|
+
*/
|
|
300
|
+
getEscrowStruct(): any;
|
|
301
|
+
}
|
|
302
|
+
export declare class SolanaSwapDataV1 extends SolanaSwapData {
|
|
303
|
+
/**
|
|
304
|
+
* Creates swap data from structured constructor arguments.
|
|
305
|
+
*
|
|
306
|
+
* @param args Swap data fields
|
|
307
|
+
*/
|
|
308
|
+
constructor(args: SolanaSwapDataCtorArgs);
|
|
309
|
+
/**
|
|
310
|
+
* Deserializes swap data from serialized storage representation.
|
|
311
|
+
*
|
|
312
|
+
* @param data Serialized swap data from {@link SolanaSwapData.serialize}
|
|
313
|
+
*/
|
|
314
|
+
constructor(data: {
|
|
315
|
+
type: "sol";
|
|
316
|
+
} & Serialized<SolanaSwapData>);
|
|
317
|
+
}
|
|
318
|
+
export declare class SolanaSwapDataV2 extends SolanaSwapData {
|
|
319
|
+
/**
|
|
320
|
+
* Creates swap data from structured constructor arguments.
|
|
321
|
+
*
|
|
322
|
+
* @param args Swap data fields
|
|
323
|
+
*/
|
|
324
|
+
constructor(args: SolanaSwapDataCtorArgs);
|
|
325
|
+
/**
|
|
326
|
+
* Deserializes swap data from serialized storage representation.
|
|
327
|
+
*
|
|
328
|
+
* @param data Serialized swap data from {@link SolanaSwapData.serialize}
|
|
329
|
+
*/
|
|
330
|
+
constructor(data: {
|
|
331
|
+
type: "sol";
|
|
332
|
+
} & Serialized<SolanaSwapData>);
|
|
333
|
+
}
|