@atomiqlabs/chain-solana 12.0.12 → 12.0.13
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/dist/index.d.ts +29 -29
- package/dist/index.js +45 -45
- package/dist/solana/SolanaChainType.d.ts +11 -11
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +20 -20
- package/dist/solana/SolanaChains.js +25 -25
- package/dist/solana/SolanaInitializer.d.ts +18 -18
- package/dist/solana/SolanaInitializer.js +63 -63
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +228 -228
- package/dist/solana/btcrelay/SolanaBtcRelay.js +441 -441
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +29 -29
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +34 -34
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +46 -46
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +78 -78
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +86 -86
- package/dist/solana/chain/SolanaChainInterface.d.ts +65 -65
- package/dist/solana/chain/SolanaChainInterface.js +125 -125
- 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 +28 -28
- package/dist/solana/chain/modules/SolanaBlocks.js +72 -72
- package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
- package/dist/solana/chain/modules/SolanaEvents.js +225 -225
- package/dist/solana/chain/modules/SolanaFees.d.ts +121 -121
- package/dist/solana/chain/modules/SolanaFees.js +379 -379
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +23 -23
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +31 -31
- package/dist/solana/chain/modules/SolanaSlots.js +68 -68
- package/dist/solana/chain/modules/SolanaTokens.d.ts +136 -136
- package/dist/solana/chain/modules/SolanaTokens.js +248 -248
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +124 -124
- package/dist/solana/chain/modules/SolanaTransactions.js +323 -323
- package/dist/solana/events/SolanaChainEvents.d.ts +88 -88
- package/dist/solana/events/SolanaChainEvents.js +256 -256
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +75 -75
- package/dist/solana/events/SolanaChainEventsBrowser.js +172 -172
- package/dist/solana/program/SolanaProgramBase.d.ts +40 -40
- package/dist/solana/program/SolanaProgramBase.js +43 -43
- 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 +114 -114
- package/dist/solana/swaps/SolanaSwapData.d.ts +71 -71
- package/dist/solana/swaps/SolanaSwapData.js +292 -292
- package/dist/solana/swaps/SolanaSwapModule.d.ts +10 -10
- package/dist/solana/swaps/SolanaSwapModule.js +11 -11
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +224 -224
- package/dist/solana/swaps/SolanaSwapProgram.js +570 -570
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +42 -42
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +94 -94
- package/dist/solana/swaps/modules/SolanaDataAccount.js +231 -231
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +71 -71
- package/dist/solana/swaps/modules/SolanaLpVault.js +173 -173
- package/dist/solana/swaps/modules/SwapClaim.d.ts +129 -129
- package/dist/solana/swaps/modules/SwapClaim.js +291 -291
- package/dist/solana/swaps/modules/SwapInit.d.ts +217 -217
- package/dist/solana/swaps/modules/SwapInit.js +519 -519
- package/dist/solana/swaps/modules/SwapRefund.d.ts +82 -82
- package/dist/solana/swaps/modules/SwapRefund.js +262 -262
- 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/wallet/SolanaKeypairWallet.d.ts +9 -9
- package/dist/solana/wallet/SolanaKeypairWallet.js +33 -33
- package/dist/solana/wallet/SolanaSigner.d.ts +11 -11
- package/dist/solana/wallet/SolanaSigner.js +17 -17
- package/dist/utils/Utils.d.ts +53 -53
- package/dist/utils/Utils.js +170 -170
- package/package.json +41 -41
- package/src/index.ts +36 -36
- package/src/solana/SolanaChainType.ts +27 -27
- package/src/solana/SolanaChains.ts +23 -23
- package/src/solana/SolanaInitializer.ts +102 -102
- package/src/solana/btcrelay/SolanaBtcRelay.ts +589 -589
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +57 -57
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +102 -102
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +108 -108
- package/src/solana/chain/SolanaChainInterface.ts +192 -192
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +78 -78
- package/src/solana/chain/modules/SolanaEvents.ts +256 -256
- package/src/solana/chain/modules/SolanaFees.ts +450 -450
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +82 -82
- package/src/solana/chain/modules/SolanaTokens.ts +307 -307
- package/src/solana/chain/modules/SolanaTransactions.ts +365 -365
- package/src/solana/events/SolanaChainEvents.ts +299 -299
- package/src/solana/events/SolanaChainEventsBrowser.ts +209 -209
- package/src/solana/program/SolanaProgramBase.ts +79 -79
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +155 -155
- package/src/solana/swaps/SolanaSwapData.ts +430 -430
- package/src/solana/swaps/SolanaSwapModule.ts +16 -16
- package/src/solana/swaps/SolanaSwapProgram.ts +854 -854
- package/src/solana/swaps/SwapTypeEnum.ts +29 -29
- package/src/solana/swaps/modules/SolanaDataAccount.ts +307 -307
- package/src/solana/swaps/modules/SolanaLpVault.ts +215 -215
- package/src/solana/swaps/modules/SwapClaim.ts +389 -389
- package/src/solana/swaps/modules/SwapInit.ts +663 -663
- package/src/solana/swaps/modules/SwapRefund.ts +323 -323
- package/src/solana/swaps/programIdl.json +944 -944
- package/src/solana/swaps/programTypes.ts +1885 -1885
- package/src/solana/wallet/SolanaKeypairWallet.ts +36 -36
- package/src/solana/wallet/SolanaSigner.ts +24 -24
- package/src/utils/Utils.ts +180 -180
|
@@ -1,224 +1,224 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SolanaSwapData } from "./SolanaSwapData";
|
|
3
|
-
import { PublicKey } from "@solana/web3.js";
|
|
4
|
-
import { SolanaBtcRelay } from "../btcrelay/SolanaBtcRelay";
|
|
5
|
-
import { IStorageManager, SwapContract, ChainSwapType, IntermediaryReputationType, TransactionConfirmationOptions, SignatureData, RelaySynchronizer, SwapCommitState, SwapCommitStateType } from "@atomiqlabs/base";
|
|
6
|
-
import { SolanaBtcStoredHeader } from "../btcrelay/headers/SolanaBtcStoredHeader";
|
|
7
|
-
import { SwapProgram } from "./programTypes";
|
|
8
|
-
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
9
|
-
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
10
|
-
import { SolanaTx } from "../chain/modules/SolanaTransactions";
|
|
11
|
-
import { SwapInit, SolanaPreFetchData, SolanaPreFetchVerification } from "./modules/SwapInit";
|
|
12
|
-
import { SolanaDataAccount, StoredDataAccount } from "./modules/SolanaDataAccount";
|
|
13
|
-
import { SwapRefund } from "./modules/SwapRefund";
|
|
14
|
-
import { SwapClaim } from "./modules/SwapClaim";
|
|
15
|
-
import { SolanaLpVault } from "./modules/SolanaLpVault";
|
|
16
|
-
import { Buffer } from "buffer";
|
|
17
|
-
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
18
|
-
export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> implements SwapContract<SolanaSwapData, SolanaTx, SolanaPreFetchData, SolanaPreFetchVerification, SolanaSigner, "SOLANA"> {
|
|
19
|
-
readonly ESCROW_STATE_RENT_EXEMPT = 2658720;
|
|
20
|
-
readonly SwapVaultAuthority: PublicKey;
|
|
21
|
-
readonly SwapVault: (tokenAddress: PublicKey) => PublicKey;
|
|
22
|
-
readonly SwapUserVault: (publicKey: PublicKey, tokenAddress: PublicKey) => PublicKey;
|
|
23
|
-
readonly SwapEscrowState: (hash: Buffer) => PublicKey;
|
|
24
|
-
readonly chainId: "SOLANA";
|
|
25
|
-
readonly claimWithSecretTimeout: number;
|
|
26
|
-
readonly claimWithTxDataTimeout: number;
|
|
27
|
-
readonly refundTimeout: number;
|
|
28
|
-
readonly claimGracePeriod: number;
|
|
29
|
-
readonly refundGracePeriod: number;
|
|
30
|
-
readonly authGracePeriod: number;
|
|
31
|
-
readonly Init: SwapInit;
|
|
32
|
-
readonly Refund: SwapRefund;
|
|
33
|
-
readonly Claim: SwapClaim;
|
|
34
|
-
readonly DataAccount: SolanaDataAccount;
|
|
35
|
-
readonly LpVault: SolanaLpVault;
|
|
36
|
-
constructor(chainInterface: SolanaChainInterface, btcRelay: SolanaBtcRelay<any>, storage: IStorageManager<StoredDataAccount>, programAddress?: string);
|
|
37
|
-
start(): Promise<void>;
|
|
38
|
-
getClaimableDeposits(signer: string): Promise<{
|
|
39
|
-
count: number;
|
|
40
|
-
totalValue: bigint;
|
|
41
|
-
}>;
|
|
42
|
-
claimDeposits(signer: SolanaSigner): Promise<{
|
|
43
|
-
txIds: string[];
|
|
44
|
-
count: number;
|
|
45
|
-
totalValue: bigint;
|
|
46
|
-
}>;
|
|
47
|
-
preFetchForInitSignatureVerification(data: SolanaPreFetchData): Promise<SolanaPreFetchVerification>;
|
|
48
|
-
preFetchBlockDataForSignatures(): Promise<SolanaPreFetchData>;
|
|
49
|
-
getInitSignature(signer: SolanaSigner, swapData: SolanaSwapData, authorizationTimeout: number, preFetchedBlockData?: SolanaPreFetchData, feeRate?: string): Promise<SignatureData>;
|
|
50
|
-
isValidInitAuthorization(signer: string, swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
51
|
-
timeout: any;
|
|
52
|
-
prefix: any;
|
|
53
|
-
signature: any;
|
|
54
|
-
}, feeRate?: string, preFetchedData?: SolanaPreFetchVerification): Promise<Buffer>;
|
|
55
|
-
getInitAuthorizationExpiry(swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
56
|
-
timeout: any;
|
|
57
|
-
prefix: any;
|
|
58
|
-
signature: any;
|
|
59
|
-
}, preFetchedData?: SolanaPreFetchVerification): Promise<number>;
|
|
60
|
-
isInitAuthorizationExpired(swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
61
|
-
timeout: any;
|
|
62
|
-
prefix: any;
|
|
63
|
-
signature: any;
|
|
64
|
-
}): Promise<boolean>;
|
|
65
|
-
getRefundSignature(signer: SolanaSigner, swapData: SolanaSwapData, authorizationTimeout: number): Promise<SignatureData>;
|
|
66
|
-
isValidRefundAuthorization(swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
67
|
-
timeout: any;
|
|
68
|
-
prefix: any;
|
|
69
|
-
signature: any;
|
|
70
|
-
}): Promise<Buffer>;
|
|
71
|
-
getDataSignature(signer: SolanaSigner, data: Buffer): Promise<string>;
|
|
72
|
-
isValidDataSignature(data: Buffer, signature: string, publicKey: string): Promise<boolean>;
|
|
73
|
-
/**
|
|
74
|
-
* Checks whether the claim is claimable by us, that means not expired, we are claimer & the swap is commited
|
|
75
|
-
*
|
|
76
|
-
* @param signer
|
|
77
|
-
* @param data
|
|
78
|
-
*/
|
|
79
|
-
isClaimable(signer: string, data: SolanaSwapData): Promise<boolean>;
|
|
80
|
-
/**
|
|
81
|
-
* Checks whether a swap is commited, i.e. the swap still exists on-chain and was not claimed nor refunded
|
|
82
|
-
*
|
|
83
|
-
* @param swapData
|
|
84
|
-
*/
|
|
85
|
-
isCommited(swapData: SolanaSwapData): Promise<boolean>;
|
|
86
|
-
/**
|
|
87
|
-
* Checks whether the swap is expired, takes into consideration possible on-chain time skew, therefore for claimer
|
|
88
|
-
* the swap expires a bit sooner than it should've & for the offerer it expires a bit later
|
|
89
|
-
*
|
|
90
|
-
* @param signer
|
|
91
|
-
* @param data
|
|
92
|
-
*/
|
|
93
|
-
isExpired(signer: string, data: SolanaSwapData): Promise<boolean>;
|
|
94
|
-
/**
|
|
95
|
-
* Checks if the swap is refundable by us, checks if we are offerer, if the swap is already expired & if the swap
|
|
96
|
-
* is still commited
|
|
97
|
-
*
|
|
98
|
-
* @param signer
|
|
99
|
-
* @param data
|
|
100
|
-
*/
|
|
101
|
-
isRequestRefundable(signer: string, data: SolanaSwapData): Promise<boolean>;
|
|
102
|
-
/**
|
|
103
|
-
* Get the swap payment hash to be used for an on-chain swap, this just uses a sha256 hash of the values
|
|
104
|
-
*
|
|
105
|
-
* @param outputScript output script required to claim the swap
|
|
106
|
-
* @param amount sats sent required to claim the swap
|
|
107
|
-
* @param confirmations
|
|
108
|
-
* @param nonce swap nonce uniquely identifying the transaction to prevent replay attacks
|
|
109
|
-
*/
|
|
110
|
-
getHashForOnchain(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
111
|
-
getHashForHtlc(swapHash: Buffer): Buffer;
|
|
112
|
-
getHashForTxId(txId: string, confirmations: number): Buffer;
|
|
113
|
-
/**
|
|
114
|
-
* Gets the status of the specific swap, this also checks if we are offerer/claimer & checks for expiry (to see
|
|
115
|
-
* if swap is refundable)
|
|
116
|
-
*
|
|
117
|
-
* @param signer
|
|
118
|
-
* @param data
|
|
119
|
-
*/
|
|
120
|
-
getCommitStatus(signer: string, data: SolanaSwapData): Promise<SwapCommitState>;
|
|
121
|
-
getCommitStatuses(request: {
|
|
122
|
-
signer: string;
|
|
123
|
-
swapData: SolanaSwapData;
|
|
124
|
-
}[]): Promise<{
|
|
125
|
-
[p: string]: SwapCommitState;
|
|
126
|
-
}>;
|
|
127
|
-
/**
|
|
128
|
-
* Checks the status of the specific payment hash
|
|
129
|
-
*
|
|
130
|
-
* @param claimHash
|
|
131
|
-
*/
|
|
132
|
-
getClaimHashStatus(claimHash: string): Promise<SwapCommitStateType>;
|
|
133
|
-
/**
|
|
134
|
-
* Returns the data committed for a specific payment hash, or null if no data is currently commited for
|
|
135
|
-
* the specific swap
|
|
136
|
-
*
|
|
137
|
-
* @param claimHashHex
|
|
138
|
-
*/
|
|
139
|
-
getCommitedData(claimHashHex: string): Promise<SolanaSwapData>;
|
|
140
|
-
getHistoricalSwaps(signer: string, startBlockheight?: number): Promise<{
|
|
141
|
-
swaps: {
|
|
142
|
-
[escrowHash: string]: {
|
|
143
|
-
init?: {
|
|
144
|
-
data: SolanaSwapData;
|
|
145
|
-
getInitTxId: () => Promise<string>;
|
|
146
|
-
getTxBlock: () => Promise<{
|
|
147
|
-
blockTime: number;
|
|
148
|
-
blockHeight: number;
|
|
149
|
-
}>;
|
|
150
|
-
};
|
|
151
|
-
state: SwapCommitState;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
latestBlockheight: number;
|
|
155
|
-
}>;
|
|
156
|
-
createSwapData(type: ChainSwapType, offerer: string, claimer: string, token: string, amount: bigint, claimHash: string, sequence: bigint, expiry: bigint, payIn: boolean, payOut: boolean, securityDeposit: bigint, claimerBounty: bigint, depositToken?: string): Promise<SolanaSwapData>;
|
|
157
|
-
getBalance(signer: string, tokenAddress: string, inContract: boolean): Promise<bigint>;
|
|
158
|
-
getIntermediaryData(address: string, token: string): Promise<{
|
|
159
|
-
balance: bigint;
|
|
160
|
-
reputation: IntermediaryReputationType;
|
|
161
|
-
}>;
|
|
162
|
-
getIntermediaryReputation(address: string, token: string): Promise<IntermediaryReputationType>;
|
|
163
|
-
getIntermediaryBalance(address: PublicKey, token: PublicKey): Promise<bigint>;
|
|
164
|
-
txsClaimWithSecret(signer: string | SolanaSigner, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<SolanaTx[]>;
|
|
165
|
-
txsClaimWithTxData(signer: string | SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
166
|
-
blockhash: string;
|
|
167
|
-
confirmations: number;
|
|
168
|
-
txid: string;
|
|
169
|
-
hex: string;
|
|
170
|
-
height: number;
|
|
171
|
-
}, requiredConfirmations: number, vout: number, commitedHeader?: SolanaBtcStoredHeader, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, feeRate?: string, storageAccHolder?: {
|
|
172
|
-
storageAcc: PublicKey;
|
|
173
|
-
}): Promise<SolanaTx[] | null>;
|
|
174
|
-
txsRefund(signer: string, swapData: SolanaSwapData, check?: boolean, initAta?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
175
|
-
txsRefundWithAuthorization(signer: string, swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
176
|
-
timeout: any;
|
|
177
|
-
prefix: any;
|
|
178
|
-
signature: any;
|
|
179
|
-
}, check?: boolean, initAta?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
180
|
-
txsInit(sender: string, swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
181
|
-
timeout: any;
|
|
182
|
-
prefix: any;
|
|
183
|
-
signature: any;
|
|
184
|
-
}, skipChecks?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
185
|
-
txsWithdraw(signer: string, token: string, amount: bigint, feeRate?: string): Promise<SolanaTx[]>;
|
|
186
|
-
txsDeposit(signer: string, token: string, amount: bigint, feeRate?: string): Promise<SolanaTx[]>;
|
|
187
|
-
claimWithSecret(signer: SolanaSigner, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
188
|
-
claimWithTxData(signer: SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
189
|
-
blockhash: string;
|
|
190
|
-
confirmations: number;
|
|
191
|
-
txid: string;
|
|
192
|
-
hex: string;
|
|
193
|
-
height: number;
|
|
194
|
-
}, requiredConfirmations: number, vout: number, commitedHeader?: SolanaBtcStoredHeader, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
195
|
-
refund(signer: SolanaSigner, swapData: SolanaSwapData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
196
|
-
refundWithAuthorization(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
197
|
-
init(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
198
|
-
initAndClaimWithSecret(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, secret: string, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string[]>;
|
|
199
|
-
withdraw(signer: SolanaSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
200
|
-
deposit(signer: SolanaSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
201
|
-
getInitPayInFeeRate(offerer?: string, claimer?: string, token?: string, claimHash?: string): Promise<string>;
|
|
202
|
-
getInitFeeRate(offerer?: string, claimer?: string, token?: string, claimHash?: string): Promise<string>;
|
|
203
|
-
getRefundFeeRate(swapData: SolanaSwapData): Promise<string>;
|
|
204
|
-
getClaimFeeRate(signer: string, swapData: SolanaSwapData): Promise<string>;
|
|
205
|
-
getClaimFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
206
|
-
getRawClaimFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
207
|
-
/**
|
|
208
|
-
* Get the estimated solana fee of the commit transaction
|
|
209
|
-
*/
|
|
210
|
-
getCommitFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
211
|
-
/**
|
|
212
|
-
* Get the estimated solana fee of the commit transaction, without any deposits
|
|
213
|
-
*/
|
|
214
|
-
getRawCommitFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
215
|
-
/**
|
|
216
|
-
* Get the estimated solana transaction fee of the refund transaction
|
|
217
|
-
*/
|
|
218
|
-
getRefundFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
219
|
-
/**
|
|
220
|
-
* Get the estimated solana transaction fee of the refund transaction
|
|
221
|
-
*/
|
|
222
|
-
getRawRefundFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
223
|
-
getExtraData(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
224
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SolanaSwapData } from "./SolanaSwapData";
|
|
3
|
+
import { PublicKey } from "@solana/web3.js";
|
|
4
|
+
import { SolanaBtcRelay } from "../btcrelay/SolanaBtcRelay";
|
|
5
|
+
import { IStorageManager, SwapContract, ChainSwapType, IntermediaryReputationType, TransactionConfirmationOptions, SignatureData, RelaySynchronizer, SwapCommitState, SwapCommitStateType } from "@atomiqlabs/base";
|
|
6
|
+
import { SolanaBtcStoredHeader } from "../btcrelay/headers/SolanaBtcStoredHeader";
|
|
7
|
+
import { SwapProgram } from "./programTypes";
|
|
8
|
+
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
9
|
+
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
10
|
+
import { SolanaTx } from "../chain/modules/SolanaTransactions";
|
|
11
|
+
import { SwapInit, SolanaPreFetchData, SolanaPreFetchVerification } from "./modules/SwapInit";
|
|
12
|
+
import { SolanaDataAccount, StoredDataAccount } from "./modules/SolanaDataAccount";
|
|
13
|
+
import { SwapRefund } from "./modules/SwapRefund";
|
|
14
|
+
import { SwapClaim } from "./modules/SwapClaim";
|
|
15
|
+
import { SolanaLpVault } from "./modules/SolanaLpVault";
|
|
16
|
+
import { Buffer } from "buffer";
|
|
17
|
+
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
18
|
+
export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> implements SwapContract<SolanaSwapData, SolanaTx, SolanaPreFetchData, SolanaPreFetchVerification, SolanaSigner, "SOLANA"> {
|
|
19
|
+
readonly ESCROW_STATE_RENT_EXEMPT = 2658720;
|
|
20
|
+
readonly SwapVaultAuthority: PublicKey;
|
|
21
|
+
readonly SwapVault: (tokenAddress: PublicKey) => PublicKey;
|
|
22
|
+
readonly SwapUserVault: (publicKey: PublicKey, tokenAddress: PublicKey) => PublicKey;
|
|
23
|
+
readonly SwapEscrowState: (hash: Buffer) => PublicKey;
|
|
24
|
+
readonly chainId: "SOLANA";
|
|
25
|
+
readonly claimWithSecretTimeout: number;
|
|
26
|
+
readonly claimWithTxDataTimeout: number;
|
|
27
|
+
readonly refundTimeout: number;
|
|
28
|
+
readonly claimGracePeriod: number;
|
|
29
|
+
readonly refundGracePeriod: number;
|
|
30
|
+
readonly authGracePeriod: number;
|
|
31
|
+
readonly Init: SwapInit;
|
|
32
|
+
readonly Refund: SwapRefund;
|
|
33
|
+
readonly Claim: SwapClaim;
|
|
34
|
+
readonly DataAccount: SolanaDataAccount;
|
|
35
|
+
readonly LpVault: SolanaLpVault;
|
|
36
|
+
constructor(chainInterface: SolanaChainInterface, btcRelay: SolanaBtcRelay<any>, storage: IStorageManager<StoredDataAccount>, programAddress?: string);
|
|
37
|
+
start(): Promise<void>;
|
|
38
|
+
getClaimableDeposits(signer: string): Promise<{
|
|
39
|
+
count: number;
|
|
40
|
+
totalValue: bigint;
|
|
41
|
+
}>;
|
|
42
|
+
claimDeposits(signer: SolanaSigner): Promise<{
|
|
43
|
+
txIds: string[];
|
|
44
|
+
count: number;
|
|
45
|
+
totalValue: bigint;
|
|
46
|
+
}>;
|
|
47
|
+
preFetchForInitSignatureVerification(data: SolanaPreFetchData): Promise<SolanaPreFetchVerification>;
|
|
48
|
+
preFetchBlockDataForSignatures(): Promise<SolanaPreFetchData>;
|
|
49
|
+
getInitSignature(signer: SolanaSigner, swapData: SolanaSwapData, authorizationTimeout: number, preFetchedBlockData?: SolanaPreFetchData, feeRate?: string): Promise<SignatureData>;
|
|
50
|
+
isValidInitAuthorization(signer: string, swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
51
|
+
timeout: any;
|
|
52
|
+
prefix: any;
|
|
53
|
+
signature: any;
|
|
54
|
+
}, feeRate?: string, preFetchedData?: SolanaPreFetchVerification): Promise<Buffer>;
|
|
55
|
+
getInitAuthorizationExpiry(swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
56
|
+
timeout: any;
|
|
57
|
+
prefix: any;
|
|
58
|
+
signature: any;
|
|
59
|
+
}, preFetchedData?: SolanaPreFetchVerification): Promise<number>;
|
|
60
|
+
isInitAuthorizationExpired(swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
61
|
+
timeout: any;
|
|
62
|
+
prefix: any;
|
|
63
|
+
signature: any;
|
|
64
|
+
}): Promise<boolean>;
|
|
65
|
+
getRefundSignature(signer: SolanaSigner, swapData: SolanaSwapData, authorizationTimeout: number): Promise<SignatureData>;
|
|
66
|
+
isValidRefundAuthorization(swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
67
|
+
timeout: any;
|
|
68
|
+
prefix: any;
|
|
69
|
+
signature: any;
|
|
70
|
+
}): Promise<Buffer>;
|
|
71
|
+
getDataSignature(signer: SolanaSigner, data: Buffer): Promise<string>;
|
|
72
|
+
isValidDataSignature(data: Buffer, signature: string, publicKey: string): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Checks whether the claim is claimable by us, that means not expired, we are claimer & the swap is commited
|
|
75
|
+
*
|
|
76
|
+
* @param signer
|
|
77
|
+
* @param data
|
|
78
|
+
*/
|
|
79
|
+
isClaimable(signer: string, data: SolanaSwapData): Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* Checks whether a swap is commited, i.e. the swap still exists on-chain and was not claimed nor refunded
|
|
82
|
+
*
|
|
83
|
+
* @param swapData
|
|
84
|
+
*/
|
|
85
|
+
isCommited(swapData: SolanaSwapData): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Checks whether the swap is expired, takes into consideration possible on-chain time skew, therefore for claimer
|
|
88
|
+
* the swap expires a bit sooner than it should've & for the offerer it expires a bit later
|
|
89
|
+
*
|
|
90
|
+
* @param signer
|
|
91
|
+
* @param data
|
|
92
|
+
*/
|
|
93
|
+
isExpired(signer: string, data: SolanaSwapData): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Checks if the swap is refundable by us, checks if we are offerer, if the swap is already expired & if the swap
|
|
96
|
+
* is still commited
|
|
97
|
+
*
|
|
98
|
+
* @param signer
|
|
99
|
+
* @param data
|
|
100
|
+
*/
|
|
101
|
+
isRequestRefundable(signer: string, data: SolanaSwapData): Promise<boolean>;
|
|
102
|
+
/**
|
|
103
|
+
* Get the swap payment hash to be used for an on-chain swap, this just uses a sha256 hash of the values
|
|
104
|
+
*
|
|
105
|
+
* @param outputScript output script required to claim the swap
|
|
106
|
+
* @param amount sats sent required to claim the swap
|
|
107
|
+
* @param confirmations
|
|
108
|
+
* @param nonce swap nonce uniquely identifying the transaction to prevent replay attacks
|
|
109
|
+
*/
|
|
110
|
+
getHashForOnchain(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
111
|
+
getHashForHtlc(swapHash: Buffer): Buffer;
|
|
112
|
+
getHashForTxId(txId: string, confirmations: number): Buffer;
|
|
113
|
+
/**
|
|
114
|
+
* Gets the status of the specific swap, this also checks if we are offerer/claimer & checks for expiry (to see
|
|
115
|
+
* if swap is refundable)
|
|
116
|
+
*
|
|
117
|
+
* @param signer
|
|
118
|
+
* @param data
|
|
119
|
+
*/
|
|
120
|
+
getCommitStatus(signer: string, data: SolanaSwapData): Promise<SwapCommitState>;
|
|
121
|
+
getCommitStatuses(request: {
|
|
122
|
+
signer: string;
|
|
123
|
+
swapData: SolanaSwapData;
|
|
124
|
+
}[]): Promise<{
|
|
125
|
+
[p: string]: SwapCommitState;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Checks the status of the specific payment hash
|
|
129
|
+
*
|
|
130
|
+
* @param claimHash
|
|
131
|
+
*/
|
|
132
|
+
getClaimHashStatus(claimHash: string): Promise<SwapCommitStateType>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the data committed for a specific payment hash, or null if no data is currently commited for
|
|
135
|
+
* the specific swap
|
|
136
|
+
*
|
|
137
|
+
* @param claimHashHex
|
|
138
|
+
*/
|
|
139
|
+
getCommitedData(claimHashHex: string): Promise<SolanaSwapData>;
|
|
140
|
+
getHistoricalSwaps(signer: string, startBlockheight?: number): Promise<{
|
|
141
|
+
swaps: {
|
|
142
|
+
[escrowHash: string]: {
|
|
143
|
+
init?: {
|
|
144
|
+
data: SolanaSwapData;
|
|
145
|
+
getInitTxId: () => Promise<string>;
|
|
146
|
+
getTxBlock: () => Promise<{
|
|
147
|
+
blockTime: number;
|
|
148
|
+
blockHeight: number;
|
|
149
|
+
}>;
|
|
150
|
+
};
|
|
151
|
+
state: SwapCommitState;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
latestBlockheight: number;
|
|
155
|
+
}>;
|
|
156
|
+
createSwapData(type: ChainSwapType, offerer: string, claimer: string, token: string, amount: bigint, claimHash: string, sequence: bigint, expiry: bigint, payIn: boolean, payOut: boolean, securityDeposit: bigint, claimerBounty: bigint, depositToken?: string): Promise<SolanaSwapData>;
|
|
157
|
+
getBalance(signer: string, tokenAddress: string, inContract: boolean): Promise<bigint>;
|
|
158
|
+
getIntermediaryData(address: string, token: string): Promise<{
|
|
159
|
+
balance: bigint;
|
|
160
|
+
reputation: IntermediaryReputationType;
|
|
161
|
+
}>;
|
|
162
|
+
getIntermediaryReputation(address: string, token: string): Promise<IntermediaryReputationType>;
|
|
163
|
+
getIntermediaryBalance(address: PublicKey, token: PublicKey): Promise<bigint>;
|
|
164
|
+
txsClaimWithSecret(signer: string | SolanaSigner, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<SolanaTx[]>;
|
|
165
|
+
txsClaimWithTxData(signer: string | SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
166
|
+
blockhash: string;
|
|
167
|
+
confirmations: number;
|
|
168
|
+
txid: string;
|
|
169
|
+
hex: string;
|
|
170
|
+
height: number;
|
|
171
|
+
}, requiredConfirmations: number, vout: number, commitedHeader?: SolanaBtcStoredHeader, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, feeRate?: string, storageAccHolder?: {
|
|
172
|
+
storageAcc: PublicKey;
|
|
173
|
+
}): Promise<SolanaTx[] | null>;
|
|
174
|
+
txsRefund(signer: string, swapData: SolanaSwapData, check?: boolean, initAta?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
175
|
+
txsRefundWithAuthorization(signer: string, swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
176
|
+
timeout: any;
|
|
177
|
+
prefix: any;
|
|
178
|
+
signature: any;
|
|
179
|
+
}, check?: boolean, initAta?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
180
|
+
txsInit(sender: string, swapData: SolanaSwapData, { timeout, prefix, signature }: {
|
|
181
|
+
timeout: any;
|
|
182
|
+
prefix: any;
|
|
183
|
+
signature: any;
|
|
184
|
+
}, skipChecks?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
185
|
+
txsWithdraw(signer: string, token: string, amount: bigint, feeRate?: string): Promise<SolanaTx[]>;
|
|
186
|
+
txsDeposit(signer: string, token: string, amount: bigint, feeRate?: string): Promise<SolanaTx[]>;
|
|
187
|
+
claimWithSecret(signer: SolanaSigner, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
188
|
+
claimWithTxData(signer: SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
189
|
+
blockhash: string;
|
|
190
|
+
confirmations: number;
|
|
191
|
+
txid: string;
|
|
192
|
+
hex: string;
|
|
193
|
+
height: number;
|
|
194
|
+
}, requiredConfirmations: number, vout: number, commitedHeader?: SolanaBtcStoredHeader, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
195
|
+
refund(signer: SolanaSigner, swapData: SolanaSwapData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
196
|
+
refundWithAuthorization(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, check?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
197
|
+
init(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
198
|
+
initAndClaimWithSecret(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, secret: string, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string[]>;
|
|
199
|
+
withdraw(signer: SolanaSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
200
|
+
deposit(signer: SolanaSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
201
|
+
getInitPayInFeeRate(offerer?: string, claimer?: string, token?: string, claimHash?: string): Promise<string>;
|
|
202
|
+
getInitFeeRate(offerer?: string, claimer?: string, token?: string, claimHash?: string): Promise<string>;
|
|
203
|
+
getRefundFeeRate(swapData: SolanaSwapData): Promise<string>;
|
|
204
|
+
getClaimFeeRate(signer: string, swapData: SolanaSwapData): Promise<string>;
|
|
205
|
+
getClaimFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
206
|
+
getRawClaimFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
207
|
+
/**
|
|
208
|
+
* Get the estimated solana fee of the commit transaction
|
|
209
|
+
*/
|
|
210
|
+
getCommitFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
211
|
+
/**
|
|
212
|
+
* Get the estimated solana fee of the commit transaction, without any deposits
|
|
213
|
+
*/
|
|
214
|
+
getRawCommitFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
215
|
+
/**
|
|
216
|
+
* Get the estimated solana transaction fee of the refund transaction
|
|
217
|
+
*/
|
|
218
|
+
getRefundFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
219
|
+
/**
|
|
220
|
+
* Get the estimated solana transaction fee of the refund transaction
|
|
221
|
+
*/
|
|
222
|
+
getRawRefundFee(signer: string, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
223
|
+
getExtraData(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
224
|
+
}
|