@lendasat/lendaswap-sdk-pure 0.2.21-preview.0 → 0.2.21
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/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -1
- package/dist/api/client.js.map +1 -1
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +4 -1
- package/dist/price-feed.d.ts +0 -124
- package/dist/price-feed.d.ts.map +0 -1
- package/dist/price-feed.js +0 -178
- package/dist/price-feed.js.map +0 -1
- package/dist/src/api/client.d.ts +0 -31
- package/dist/src/api/client.d.ts.map +0 -1
- package/dist/src/api/client.js +0 -12
- package/dist/src/api/client.js.map +0 -1
- package/dist/src/arkade.d.ts +0 -36
- package/dist/src/arkade.d.ts.map +0 -1
- package/dist/src/arkade.js +0 -68
- package/dist/src/arkade.js.map +0 -1
- package/dist/src/client.d.ts +0 -760
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js +0 -2169
- package/dist/src/client.js.map +0 -1
- package/dist/src/create/arkade.d.ts +0 -34
- package/dist/src/create/arkade.d.ts.map +0 -1
- package/dist/src/create/arkade.js +0 -76
- package/dist/src/create/arkade.js.map +0 -1
- package/dist/src/create/bitcoin-to-arkade.d.ts +0 -36
- package/dist/src/create/bitcoin-to-arkade.d.ts.map +0 -1
- package/dist/src/create/bitcoin-to-arkade.js +0 -69
- package/dist/src/create/bitcoin-to-arkade.js.map +0 -1
- package/dist/src/create/bitcoin.d.ts +0 -31
- package/dist/src/create/bitcoin.d.ts.map +0 -1
- package/dist/src/create/bitcoin.js +0 -67
- package/dist/src/create/bitcoin.js.map +0 -1
- package/dist/src/create/evm-to-arkade.d.ts +0 -34
- package/dist/src/create/evm-to-arkade.d.ts.map +0 -1
- package/dist/src/create/evm-to-arkade.js +0 -69
- package/dist/src/create/evm-to-arkade.js.map +0 -1
- package/dist/src/create/evm-to-bitcoin.d.ts +0 -35
- package/dist/src/create/evm-to-bitcoin.d.ts.map +0 -1
- package/dist/src/create/evm-to-bitcoin.js +0 -71
- package/dist/src/create/evm-to-bitcoin.js.map +0 -1
- package/dist/src/create/evm-to-lightning.d.ts +0 -34
- package/dist/src/create/evm-to-lightning.d.ts.map +0 -1
- package/dist/src/create/evm-to-lightning.js +0 -66
- package/dist/src/create/evm-to-lightning.js.map +0 -1
- package/dist/src/create/index.d.ts +0 -19
- package/dist/src/create/index.d.ts.map +0 -1
- package/dist/src/create/index.js +0 -18
- package/dist/src/create/index.js.map +0 -1
- package/dist/src/create/lightning.d.ts +0 -31
- package/dist/src/create/lightning.d.ts.map +0 -1
- package/dist/src/create/lightning.js +0 -72
- package/dist/src/create/lightning.js.map +0 -1
- package/dist/src/create/types.d.ts +0 -247
- package/dist/src/create/types.d.ts.map +0 -1
- package/dist/src/create/types.js +0 -5
- package/dist/src/create/types.js.map +0 -1
- package/dist/src/delegate.d.ts +0 -62
- package/dist/src/delegate.d.ts.map +0 -1
- package/dist/src/delegate.js +0 -284
- package/dist/src/delegate.js.map +0 -1
- package/dist/src/esplora.d.ts +0 -41
- package/dist/src/esplora.d.ts.map +0 -1
- package/dist/src/esplora.js +0 -47
- package/dist/src/esplora.js.map +0 -1
- package/dist/src/evm/coordinator.d.ts +0 -247
- package/dist/src/evm/coordinator.d.ts.map +0 -1
- package/dist/src/evm/coordinator.js +0 -414
- package/dist/src/evm/coordinator.js.map +0 -1
- package/dist/src/evm/htlc.d.ts +0 -238
- package/dist/src/evm/htlc.d.ts.map +0 -1
- package/dist/src/evm/htlc.js +0 -278
- package/dist/src/evm/htlc.js.map +0 -1
- package/dist/src/evm/index.d.ts +0 -9
- package/dist/src/evm/index.d.ts.map +0 -1
- package/dist/src/evm/index.js +0 -9
- package/dist/src/evm/index.js.map +0 -1
- package/dist/src/evm/signing.d.ts +0 -30
- package/dist/src/evm/signing.d.ts.map +0 -1
- package/dist/src/evm/signing.js +0 -91
- package/dist/src/evm/signing.js.map +0 -1
- package/dist/src/generated/api.d.ts +0 -2736
- package/dist/src/generated/api.d.ts.map +0 -1
- package/dist/src/generated/api.js +0 -6
- package/dist/src/generated/api.js.map +0 -1
- package/dist/src/index.d.ts +0 -18
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -24
- package/dist/src/index.js.map +0 -1
- package/dist/src/node.d.ts +0 -19
- package/dist/src/node.d.ts.map +0 -1
- package/dist/src/node.js +0 -19
- package/dist/src/node.js.map +0 -1
- package/dist/src/price-calculations.d.ts +0 -109
- package/dist/src/price-calculations.d.ts.map +0 -1
- package/dist/src/price-calculations.js +0 -135
- package/dist/src/price-calculations.js.map +0 -1
- package/dist/src/redeem/arkade.d.ts +0 -65
- package/dist/src/redeem/arkade.d.ts.map +0 -1
- package/dist/src/redeem/arkade.js +0 -217
- package/dist/src/redeem/arkade.js.map +0 -1
- package/dist/src/redeem/ethereum.d.ts +0 -52
- package/dist/src/redeem/ethereum.d.ts.map +0 -1
- package/dist/src/redeem/ethereum.js +0 -206
- package/dist/src/redeem/ethereum.js.map +0 -1
- package/dist/src/redeem/gasless.d.ts +0 -41
- package/dist/src/redeem/gasless.d.ts.map +0 -1
- package/dist/src/redeem/gasless.js +0 -71
- package/dist/src/redeem/gasless.js.map +0 -1
- package/dist/src/redeem/index.d.ts +0 -49
- package/dist/src/redeem/index.d.ts.map +0 -1
- package/dist/src/redeem/index.js +0 -189
- package/dist/src/redeem/index.js.map +0 -1
- package/dist/src/redeem/types.d.ts +0 -126
- package/dist/src/redeem/types.d.ts.map +0 -1
- package/dist/src/redeem/types.js +0 -36
- package/dist/src/redeem/types.js.map +0 -1
- package/dist/src/refund/arkade.d.ts +0 -62
- package/dist/src/refund/arkade.d.ts.map +0 -1
- package/dist/src/refund/arkade.js +0 -212
- package/dist/src/refund/arkade.js.map +0 -1
- package/dist/src/refund/index.d.ts +0 -10
- package/dist/src/refund/index.d.ts.map +0 -1
- package/dist/src/refund/index.js +0 -10
- package/dist/src/refund/index.js.map +0 -1
- package/dist/src/refund/onchain.d.ts +0 -137
- package/dist/src/refund/onchain.d.ts.map +0 -1
- package/dist/src/refund/onchain.js +0 -366
- package/dist/src/refund/onchain.js.map +0 -1
- package/dist/src/signer/index.d.ts +0 -106
- package/dist/src/signer/index.d.ts.map +0 -1
- package/dist/src/signer/index.js +0 -179
- package/dist/src/signer/index.js.map +0 -1
- package/dist/src/storage/idb.d.ts +0 -70
- package/dist/src/storage/idb.d.ts.map +0 -1
- package/dist/src/storage/idb.js +0 -236
- package/dist/src/storage/idb.js.map +0 -1
- package/dist/src/storage/index.d.ts +0 -152
- package/dist/src/storage/index.d.ts.map +0 -1
- package/dist/src/storage/index.js +0 -98
- package/dist/src/storage/index.js.map +0 -1
- package/dist/src/storage/sqlite.d.ts +0 -95
- package/dist/src/storage/sqlite.d.ts.map +0 -1
- package/dist/src/storage/sqlite.js +0 -206
- package/dist/src/storage/sqlite.js.map +0 -1
- package/dist/src/storage/types.d.ts +0 -57
- package/dist/src/storage/types.d.ts.map +0 -1
- package/dist/src/storage/types.js +0 -9
- package/dist/src/storage/types.js.map +0 -1
- package/dist/src/tokens.d.ts +0 -29
- package/dist/src/tokens.d.ts.map +0 -1
- package/dist/src/tokens.js +0 -89
- package/dist/src/tokens.js.map +0 -1
- package/dist/src/usd-price.d.ts +0 -34
- package/dist/src/usd-price.d.ts.map +0 -1
- package/dist/src/usd-price.js +0 -83
- package/dist/src/usd-price.js.map +0 -1
- package/dist/tests/api-client.test.d.ts +0 -2
- package/dist/tests/api-client.test.d.ts.map +0 -1
- package/dist/tests/api-client.test.js +0 -86
- package/dist/tests/api-client.test.js.map +0 -1
- package/dist/tests/client.test.d.ts +0 -2
- package/dist/tests/client.test.d.ts.map +0 -1
- package/dist/tests/client.test.js +0 -150
- package/dist/tests/client.test.js.map +0 -1
- package/dist/tests/index.test.d.ts +0 -2
- package/dist/tests/index.test.d.ts.map +0 -1
- package/dist/tests/index.test.js +0 -8
- package/dist/tests/index.test.js.map +0 -1
- package/dist/tests/onchain-refund.test.d.ts +0 -2
- package/dist/tests/onchain-refund.test.d.ts.map +0 -1
- package/dist/tests/onchain-refund.test.js +0 -279
- package/dist/tests/onchain-refund.test.js.map +0 -1
- package/dist/tests/signer.test.d.ts +0 -2
- package/dist/tests/signer.test.d.ts.map +0 -1
- package/dist/tests/signer.test.js +0 -92
- package/dist/tests/signer.test.js.map +0 -1
- package/dist/tests/sqlite-storage.test.d.ts +0 -2
- package/dist/tests/sqlite-storage.test.d.ts.map +0 -1
- package/dist/tests/sqlite-storage.test.js +0 -160
- package/dist/tests/sqlite-storage.test.js.map +0 -1
- package/dist/tests/storage.test.d.ts +0 -2
- package/dist/tests/storage.test.d.ts.map +0 -1
- package/dist/tests/storage.test.js +0 -184
- package/dist/tests/storage.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/usdt0-bridge/bridge.d.ts +0 -82
- package/dist/usdt0-bridge/bridge.d.ts.map +0 -1
- package/dist/usdt0-bridge/bridge.js +0 -56
- package/dist/usdt0-bridge/bridge.js.map +0 -1
- package/dist/usdt0-bridge/chains.d.ts +0 -41
- package/dist/usdt0-bridge/chains.d.ts.map +0 -1
- package/dist/usdt0-bridge/chains.js +0 -117
- package/dist/usdt0-bridge/chains.js.map +0 -1
- package/dist/usdt0-bridge/layerzero-tracker.d.ts +0 -34
- package/dist/usdt0-bridge/layerzero-tracker.d.ts.map +0 -1
- package/dist/usdt0-bridge/layerzero-tracker.js +0 -86
- package/dist/usdt0-bridge/layerzero-tracker.js.map +0 -1
- package/dist/usdt0-bridge/oft-abi.d.ts +0 -145
- package/dist/usdt0-bridge/oft-abi.d.ts.map +0 -1
- package/dist/usdt0-bridge/oft-abi.js +0 -117
- package/dist/usdt0-bridge/oft-abi.js.map +0 -1
package/dist/src/client.d.ts
DELETED
|
@@ -1,760 +0,0 @@
|
|
|
1
|
-
import { type ApiClient, type Chain, type GetSwapResponse, type QuoteResponse, type TokenInfos } from "./api/client.js";
|
|
2
|
-
import { type VhtlcAmounts } from "./arkade.js";
|
|
3
|
-
import { type ArkadeToEvmSwapOptions, type ArkadeToEvmSwapResult, type BitcoinToArkadeSwapOptions, type BitcoinToArkadeSwapResult, type BitcoinToEvmSwapOptions, type BitcoinToEvmSwapResult, type CreateSwapOptions, type CreateSwapResult, type EvmToArkadeSwapGenericOptions, type EvmToArkadeSwapGenericResult, type EvmToBitcoinSwapOptions, type EvmToBitcoinSwapResult, type EvmToLightningSwapGenericOptions, type EvmToLightningSwapGenericResult, type LightningToEvmSwapGenericOptions, type LightningToEvmSwapGenericResult } from "./create";
|
|
4
|
-
import { type ClaimGaslessResult, type ClaimResult } from "./redeem/index.js";
|
|
5
|
-
import { Signer, type SwapParams } from "./signer/index.js";
|
|
6
|
-
import { type StoredSwap, type SwapStorage, type WalletStorage } from "./storage";
|
|
7
|
-
export type { ArkadeToEvmSwapOptions, ArkadeToEvmSwapResult, BitcoinToArkadeSwapOptions, BitcoinToArkadeSwapResult, BitcoinToEvmSwapOptions, BitcoinToEvmSwapResponse, BitcoinToEvmSwapResult, BtcToEvmSwapOptions, CreateSwapOptions, CreateSwapResult, EvmChain, EvmToArkadeSwapGenericOptions, EvmToArkadeSwapGenericResult, EvmToArkadeSwapOptions, EvmToArkadeSwapResult, EvmToBitcoinSwapOptions, EvmToBitcoinSwapResult, EvmToLightningSwapOptions, } from "./create/index.js";
|
|
8
|
-
export { buildExecuteAndCreateCalls, buildRedeemCalls, buildRedeemDigest, type CoordinatorCall, type ExecuteAndCreateCallData, type ExecuteAndCreateParams, encodeExecuteAndCreate, encodeRedeemAndExecute, encodeRefundAndExecute, encodeRefundTo, type RedeemAndExecuteCallData, type RedeemAndExecuteParams, type RedeemDigestParams, type RefundAndExecuteParams, type RefundToParams, } from "./evm/index.js";
|
|
9
|
-
export type { ClaimGaslessResult, ClaimResult, CoordinatorClaimData, EthereumClaimData, } from "./redeem/index.js";
|
|
10
|
-
/** Result of attempting a refund */
|
|
11
|
-
export interface RefundResult {
|
|
12
|
-
/** Whether the refund was successful */
|
|
13
|
-
success: boolean;
|
|
14
|
-
/** Human-readable message about the refund status */
|
|
15
|
-
message: string;
|
|
16
|
-
/** Raw transaction hex (for on-chain refunds) */
|
|
17
|
-
txHex?: string;
|
|
18
|
-
/** Transaction ID (for on-chain refunds) */
|
|
19
|
-
txId?: string;
|
|
20
|
-
/** Amount being refunded in satoshis (after fees) */
|
|
21
|
-
refundAmount?: bigint;
|
|
22
|
-
/** Fee paid in satoshis */
|
|
23
|
-
fee?: bigint;
|
|
24
|
-
/** Whether the transaction was broadcast to the network */
|
|
25
|
-
broadcast?: boolean;
|
|
26
|
-
/** The HTLC address we computed locally (for debugging) */
|
|
27
|
-
htlcAddress?: string;
|
|
28
|
-
/** The HTLC address reported by the server (for debugging) */
|
|
29
|
-
serverHtlcAddress?: string;
|
|
30
|
-
/** EVM refund data (for evm_to_arkade and evm_to_btc swaps) */
|
|
31
|
-
evmRefundData?: {
|
|
32
|
-
/** Address to send the refund transaction to (coordinator or HTLC) */
|
|
33
|
-
to: string;
|
|
34
|
-
/** ABI-encoded calldata for the refund call */
|
|
35
|
-
data: string;
|
|
36
|
-
/** Whether the timelock has already expired (refund is available) */
|
|
37
|
-
timelockExpired: boolean;
|
|
38
|
-
/** Unix timestamp when the timelock expires */
|
|
39
|
-
timelockExpiry: number;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/** Options for on-chain refund */
|
|
43
|
-
export interface OnchainRefundOptions {
|
|
44
|
-
/** Destination address to receive refunded BTC */
|
|
45
|
-
destinationAddress: string;
|
|
46
|
-
/** Fee rate in satoshis per virtual byte (default: 2) */
|
|
47
|
-
feeRateSatPerVb?: number;
|
|
48
|
-
/** If true, only build the transaction without broadcasting (default: false) */
|
|
49
|
-
dryRun?: boolean;
|
|
50
|
-
}
|
|
51
|
-
/** Options for Arkade (off-chain) refund */
|
|
52
|
-
export interface ArkadeRefundOptions {
|
|
53
|
-
/** Destination Arkade address to receive refunded BTC */
|
|
54
|
-
destinationAddress: string;
|
|
55
|
-
/** Arkade server URL (optional, uses default based on network) */
|
|
56
|
-
arkadeServerUrl?: string;
|
|
57
|
-
}
|
|
58
|
-
/** Options for EVM refund via coordinator */
|
|
59
|
-
export interface EvmRefundOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Refund mode:
|
|
62
|
-
* - "swap-back" (default): Swap WBTC back to original token via DEX
|
|
63
|
-
* - "direct": Return WBTC directly (useful when DEX calldata is stale)
|
|
64
|
-
*/
|
|
65
|
-
mode?: "swap-back" | "direct";
|
|
66
|
-
}
|
|
67
|
-
/** General refund options — the method picks the right variant based on swap type */
|
|
68
|
-
export type RefundOptions = OnchainRefundOptions | ArkadeRefundOptions | EvmRefundOptions;
|
|
69
|
-
/** Options for Arkade (off-chain) claim */
|
|
70
|
-
export interface ArkadeClaimOptions {
|
|
71
|
-
/** Destination Arkade address to receive claimed BTC */
|
|
72
|
-
destinationAddress: string;
|
|
73
|
-
/** Arkade server URL (optional, uses default based on network) */
|
|
74
|
-
arkadeServerUrl?: string;
|
|
75
|
-
}
|
|
76
|
-
/** Options for claiming a swap */
|
|
77
|
-
export interface ClaimOptions {
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated For Arkade-to-EVM swaps, the destination is now set at swap creation time
|
|
80
|
-
* and stored on the server. This option is ignored for arkade_to_evm swaps.
|
|
81
|
-
*/
|
|
82
|
-
destination?: string;
|
|
83
|
-
/** Bitcoin destination address for EVM-to-Bitcoin claims (required for evm_to_bitcoin direction) */
|
|
84
|
-
destinationAddress?: string;
|
|
85
|
-
/** Fee rate in sat/vB for on-chain Bitcoin claims (default: 2) */
|
|
86
|
-
feeRateSatPerVb?: number;
|
|
87
|
-
}
|
|
88
|
-
/** Result of getting EVM funding call data */
|
|
89
|
-
export interface EvmFundingCallData {
|
|
90
|
-
/** Call data for approving token spend (ERC20 approve) */
|
|
91
|
-
approve: {
|
|
92
|
-
/** Token contract address to call */
|
|
93
|
-
to: string;
|
|
94
|
-
/** Encoded approve(spender, amount) call data */
|
|
95
|
-
data: string;
|
|
96
|
-
};
|
|
97
|
-
/** Call data for creating the swap (from server) */
|
|
98
|
-
createSwap: {
|
|
99
|
-
/** HTLC contract address to call */
|
|
100
|
-
to: string;
|
|
101
|
-
/** Encoded createSwap call data (from server) */
|
|
102
|
-
data: string;
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/** Result of getting coordinator funding call data for EVM-to-BTC swaps */
|
|
106
|
-
export interface CoordinatorFundingCallData {
|
|
107
|
-
/** Call data for approving source token spend to the coordinator */
|
|
108
|
-
approve: {
|
|
109
|
-
/** Source token contract address to call */
|
|
110
|
-
to: string;
|
|
111
|
-
/** Encoded approve(coordinator, amount) call data */
|
|
112
|
-
data: string;
|
|
113
|
-
};
|
|
114
|
-
/** Call data for executeAndCreate on the coordinator */
|
|
115
|
-
executeAndCreate: {
|
|
116
|
-
/** Coordinator contract address to call */
|
|
117
|
-
to: string;
|
|
118
|
-
/** Encoded executeAndCreate call data */
|
|
119
|
-
data: string;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/** Result of getting coordinator refund call data */
|
|
123
|
-
export interface CoordinatorRefundCallData {
|
|
124
|
-
/** Contract address to call */
|
|
125
|
-
to: string;
|
|
126
|
-
/** Encoded refund call data */
|
|
127
|
-
data: string;
|
|
128
|
-
/** Whether the timelock has expired (refund is possible) */
|
|
129
|
-
timelockExpired: boolean;
|
|
130
|
-
/** Unix timestamp when the timelock expires */
|
|
131
|
-
timelockExpiry: number;
|
|
132
|
-
/** Refund mode used */
|
|
133
|
-
mode: "swap-back" | "direct";
|
|
134
|
-
}
|
|
135
|
-
/** Configuration options for the Lendaswap client. */
|
|
136
|
-
export interface ClientConfig {
|
|
137
|
-
/** The base URL of the Lendaswap API. */
|
|
138
|
-
baseUrl: string;
|
|
139
|
-
/** Optional API key for authenticated requests. */
|
|
140
|
-
apiKey?: string;
|
|
141
|
-
/** Optional Esplora API URL for broadcasting Bitcoin transactions. */
|
|
142
|
-
esploraUrl?: string;
|
|
143
|
-
/** Optional Arkade server URL (e.g. "https://arkade.computer"). Falls back to network-based defaults. */
|
|
144
|
-
arkadeServerUrl?: string;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Builder for creating a Lendaswap client with a fluent API.
|
|
148
|
-
*
|
|
149
|
-
* The `build()` method is async and returns a fully initialized client.
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* ```ts
|
|
153
|
-
* // Create client with new wallet (generates mnemonic)
|
|
154
|
-
* const client = await Client.builder()
|
|
155
|
-
* .withSignerStorage(new IdbWalletStorage())
|
|
156
|
-
* .build();
|
|
157
|
-
*
|
|
158
|
-
* // Create client with existing mnemonic
|
|
159
|
-
* const client = await Client.builder()
|
|
160
|
-
* .withSignerStorage(new IdbWalletStorage())
|
|
161
|
-
* .withMnemonic("abandon abandon abandon ...")
|
|
162
|
-
* .build();
|
|
163
|
-
*
|
|
164
|
-
* // Create client without storage (stateless, generates new mnemonic)
|
|
165
|
-
* const client = await Client.builder().build();
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
export declare class ClientBuilder {
|
|
169
|
-
#private;
|
|
170
|
-
/**
|
|
171
|
-
* Sets the base URL for the API.
|
|
172
|
-
* @param baseUrl - The base URL of the Lendaswap API.
|
|
173
|
-
* @returns The builder instance for chaining.
|
|
174
|
-
*/
|
|
175
|
-
withBaseUrl(baseUrl: string): this;
|
|
176
|
-
/**
|
|
177
|
-
* Sets the API key for authenticated requests.
|
|
178
|
-
* @param apiKey - The API key to use for authentication.
|
|
179
|
-
* @returns The builder instance for chaining.
|
|
180
|
-
*/
|
|
181
|
-
withApiKey(apiKey: string): this;
|
|
182
|
-
/**
|
|
183
|
-
* Sets the Esplora API URL for broadcasting Bitcoin transactions.
|
|
184
|
-
*
|
|
185
|
-
* If not set, defaults will be used based on the network:
|
|
186
|
-
* - mainnet: https://mempool.space/api
|
|
187
|
-
* - testnet: https://mempool.space/testnet/api
|
|
188
|
-
* - signet: https://mempool.space/signet/api
|
|
189
|
-
*
|
|
190
|
-
* @param esploraUrl - The Esplora API base URL.
|
|
191
|
-
* @returns The builder instance for chaining.
|
|
192
|
-
*/
|
|
193
|
-
withEsploraUrl(esploraUrl: string): this;
|
|
194
|
-
/**
|
|
195
|
-
* Sets the Arkade server URL for VHTLC operations (claim, refund, amounts).
|
|
196
|
-
*
|
|
197
|
-
* If not set, defaults are used based on the network:
|
|
198
|
-
* - bitcoin: https://arkade.computer
|
|
199
|
-
* - signet: wa
|
|
200
|
-
*
|
|
201
|
-
* @param arkadeServerUrl - The Arkade server base URL.
|
|
202
|
-
* @returns The builder instance for chaining.
|
|
203
|
-
*/
|
|
204
|
-
withArkadeServerUrl(arkadeServerUrl: string): this;
|
|
205
|
-
/**
|
|
206
|
-
* Sets the storage backend for signer data (mnemonic and key index).
|
|
207
|
-
* @param storage - The storage implementation to use.
|
|
208
|
-
* @returns The builder instance for chaining.
|
|
209
|
-
*/
|
|
210
|
-
withSignerStorage(storage: WalletStorage): this;
|
|
211
|
-
/**
|
|
212
|
-
* Sets the storage backend for swap data.
|
|
213
|
-
*
|
|
214
|
-
* When configured, swaps will be automatically persisted after creation.
|
|
215
|
-
*
|
|
216
|
-
* @param storage - The swap storage implementation to use.
|
|
217
|
-
* @returns The builder instance for chaining.
|
|
218
|
-
*/
|
|
219
|
-
withSwapStorage(storage: SwapStorage): this;
|
|
220
|
-
/**
|
|
221
|
-
* Sets the mnemonic phrase to use for the signer.
|
|
222
|
-
*
|
|
223
|
-
* If provided, this mnemonic will be used instead of loading from storage
|
|
224
|
-
* or generating a new one. The mnemonic will be persisted to storage if
|
|
225
|
-
* storage is configured.
|
|
226
|
-
*
|
|
227
|
-
* @param mnemonic - The BIP39 mnemonic phrase (12, 15, 18, 21, or 24 words).
|
|
228
|
-
* @returns The builder instance for chaining.
|
|
229
|
-
*/
|
|
230
|
-
withMnemonic(mnemonic: string): this;
|
|
231
|
-
/**
|
|
232
|
-
* Builds and returns a fully initialized Client instance.
|
|
233
|
-
*
|
|
234
|
-
* Initialization order:
|
|
235
|
-
* 1. If `withMnemonic()` was called, use that mnemonic
|
|
236
|
-
* 2. Else if storage is configured and contains a mnemonic, load it
|
|
237
|
-
* 3. Else generate a new mnemonic
|
|
238
|
-
*
|
|
239
|
-
* The mnemonic is persisted to storage if storage is configured.
|
|
240
|
-
*
|
|
241
|
-
* @returns A promise that resolves to a fully initialized Client.
|
|
242
|
-
* @throws Error if the provided mnemonic is invalid.
|
|
243
|
-
*/
|
|
244
|
-
build(): Promise<Client>;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Main client for interacting with the Lendaswap API.
|
|
248
|
-
*
|
|
249
|
-
* The client manages:
|
|
250
|
-
* - API communication
|
|
251
|
-
* - Signer (HD wallet) for key derivation
|
|
252
|
-
* - Storage for persisting mnemonic and key index
|
|
253
|
-
*
|
|
254
|
-
* Use `Client.builder()` to create a new instance.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```ts
|
|
258
|
-
* const client = await Client.builder()
|
|
259
|
-
* .withSignerStorage(new IdbWalletStorage())
|
|
260
|
-
* .withApiKey("your-api-key")
|
|
261
|
-
* .build();
|
|
262
|
-
*
|
|
263
|
-
* // Get mnemonic (for backup)
|
|
264
|
-
* const mnemonic = client.getMnemonic();
|
|
265
|
-
*
|
|
266
|
-
* // Derive swap parameters
|
|
267
|
-
* const params = await client.deriveSwapParams();
|
|
268
|
-
* ```
|
|
269
|
-
*/
|
|
270
|
-
export declare class Client {
|
|
271
|
-
#private;
|
|
272
|
-
/**
|
|
273
|
-
* Creates a new Client instance.
|
|
274
|
-
*
|
|
275
|
-
* Use `Client.builder()` instead of calling this constructor directly.
|
|
276
|
-
*
|
|
277
|
-
* @internal
|
|
278
|
-
*/
|
|
279
|
-
constructor(config: ClientConfig, signer: Signer, signerStorage?: WalletStorage, swapStorage?: SwapStorage);
|
|
280
|
-
/**
|
|
281
|
-
* Creates a new ClientBuilder for fluent configuration.
|
|
282
|
-
* @returns A new ClientBuilder instance.
|
|
283
|
-
*/
|
|
284
|
-
static builder(): ClientBuilder;
|
|
285
|
-
/** The underlying typed API client for direct API access. */
|
|
286
|
-
get api(): ApiClient;
|
|
287
|
-
/** The base URL of the API. */
|
|
288
|
-
get baseUrl(): string;
|
|
289
|
-
/** The swap storage, if configured. */
|
|
290
|
-
get swapStorage(): SwapStorage | undefined;
|
|
291
|
-
/**
|
|
292
|
-
* Gets the mnemonic phrase.
|
|
293
|
-
*
|
|
294
|
-
* Store this securely - it's the only way to recover the wallet.
|
|
295
|
-
*
|
|
296
|
-
* @returns The BIP39 mnemonic phrase.
|
|
297
|
-
*/
|
|
298
|
-
getMnemonic(): string;
|
|
299
|
-
/**
|
|
300
|
-
* Loads a mnemonic phrase, replacing the current signer.
|
|
301
|
-
*
|
|
302
|
-
* The new mnemonic is persisted to storage if storage is configured.
|
|
303
|
-
*
|
|
304
|
-
* @param mnemonic - The BIP39 mnemonic phrase to load.
|
|
305
|
-
* @throws Error if the mnemonic is invalid.
|
|
306
|
-
*/
|
|
307
|
-
loadMnemonic(mnemonic: string): Promise<void>;
|
|
308
|
-
/**
|
|
309
|
-
* Gets the user ID extended public key for wallet recovery.
|
|
310
|
-
*
|
|
311
|
-
* This can be shared with the server for recovering swap history.
|
|
312
|
-
*
|
|
313
|
-
* @returns The hex-encoded user ID xpub.
|
|
314
|
-
*/
|
|
315
|
-
getUserIdXpub(): string;
|
|
316
|
-
/**
|
|
317
|
-
* Derives swap parameters at the next available index.
|
|
318
|
-
*
|
|
319
|
-
* Automatically increments the key index in storage (if configured).
|
|
320
|
-
*
|
|
321
|
-
* @returns The derived swap parameters.
|
|
322
|
-
*/
|
|
323
|
-
deriveSwapParams(): Promise<SwapParams>;
|
|
324
|
-
/**
|
|
325
|
-
* Derives swap parameters at a specific index.
|
|
326
|
-
*
|
|
327
|
-
* Does not modify the stored key index. Useful for recovery scenarios.
|
|
328
|
-
*
|
|
329
|
-
* @param index - The key index to derive.
|
|
330
|
-
* @returns The derived swap parameters.
|
|
331
|
-
*/
|
|
332
|
-
deriveSwapParamsAtIndex(index: number): SwapParams;
|
|
333
|
-
/**
|
|
334
|
-
* Gets the current key index from storage.
|
|
335
|
-
* @returns The current key index, or 0 if no storage is configured.
|
|
336
|
-
*/
|
|
337
|
-
getKeyIndex(): Promise<number>;
|
|
338
|
-
/**
|
|
339
|
-
* Sets the key index in storage.
|
|
340
|
-
*
|
|
341
|
-
* Useful for recovery scenarios where you need to set the index
|
|
342
|
-
* to a specific value.
|
|
343
|
-
*
|
|
344
|
-
* @param index - The new key index.
|
|
345
|
-
* @throws Error if no storage is configured.
|
|
346
|
-
*/
|
|
347
|
-
setKeyIndex(index: number): Promise<void>;
|
|
348
|
-
/**
|
|
349
|
-
* Checks the health status of the API.
|
|
350
|
-
* @returns A promise that resolves to "ok" if the API is healthy.
|
|
351
|
-
* @throws Error if the health check fails.
|
|
352
|
-
*/
|
|
353
|
-
healthCheck(): Promise<string>;
|
|
354
|
-
/**
|
|
355
|
-
* Gets the version information of the API.
|
|
356
|
-
* @returns A promise that resolves to the version info containing tag and commit hash.
|
|
357
|
-
* @throws Error if the request fails.
|
|
358
|
-
*/
|
|
359
|
-
getVersion(): Promise<{
|
|
360
|
-
tag: string;
|
|
361
|
-
commit_hash: string;
|
|
362
|
-
}>;
|
|
363
|
-
/**
|
|
364
|
-
* Gets the current Median Time Past (MTP) and tip block height.
|
|
365
|
-
* @returns A promise that resolves to the MTP timestamp and tip height.
|
|
366
|
-
* @throws Error if the request fails or MTP is not yet available.
|
|
367
|
-
*/
|
|
368
|
-
getMtp(): Promise<{
|
|
369
|
-
mtp: number;
|
|
370
|
-
tip_height: number;
|
|
371
|
-
}>;
|
|
372
|
-
/**
|
|
373
|
-
* Gets the list of supported tokens.
|
|
374
|
-
* @returns A promise that resolves to an array of token information.
|
|
375
|
-
* @throws Error if the request fails.
|
|
376
|
-
*/
|
|
377
|
-
getTokens(): Promise<TokenInfos>;
|
|
378
|
-
/**
|
|
379
|
-
* Gets a quote for swapping between two tokens.
|
|
380
|
-
* @param params - Quote parameters.
|
|
381
|
-
* @param params.sourceChain - Source blockchain (e.g., "Arkade", "Polygon").
|
|
382
|
-
* @param params.sourceToken - Source token: contract address for EVM tokens, or "btc" for BTC.
|
|
383
|
-
* @param params.targetChain - Target blockchain (e.g., "Polygon", "Lightning").
|
|
384
|
-
* @param params.targetToken - Target token: contract address for EVM tokens, or "btc" for BTC.
|
|
385
|
-
* @param params.sourceAmount - Amount in smallest unit of source token (mutually exclusive with targetAmount).
|
|
386
|
-
* @param params.targetAmount - Amount in smallest unit of target token (mutually exclusive with sourceAmount).
|
|
387
|
-
* @returns A promise that resolves to the quote response with pricing details.
|
|
388
|
-
* @throws Error if the request fails.
|
|
389
|
-
*/
|
|
390
|
-
getQuote(params: {
|
|
391
|
-
sourceChain: Chain;
|
|
392
|
-
sourceToken: string;
|
|
393
|
-
targetChain: Chain;
|
|
394
|
-
targetToken: string;
|
|
395
|
-
sourceAmount?: number;
|
|
396
|
-
targetAmount?: number;
|
|
397
|
-
}): Promise<QuoteResponse>;
|
|
398
|
-
/**
|
|
399
|
-
* Gets the status and details of a swap by its ID.
|
|
400
|
-
* @param id - The UUID of the swap.
|
|
401
|
-
* @param options - Optional settings.
|
|
402
|
-
* @param options.updateStorage - If true, updates the swap in storage after fetching.
|
|
403
|
-
* @returns A promise that resolves to the swap details.
|
|
404
|
-
* @throws Error if the request fails or swap is not found.
|
|
405
|
-
*/
|
|
406
|
-
getSwap(id: string, options?: {
|
|
407
|
-
updateStorage?: boolean;
|
|
408
|
-
}): Promise<GetSwapResponse>;
|
|
409
|
-
/**
|
|
410
|
-
* Gets a swap from local storage without making a server request.
|
|
411
|
-
*
|
|
412
|
-
* Use this when you need swap data but don't need the latest status
|
|
413
|
-
* from the server. The stored swap includes the preimage, keys, and
|
|
414
|
-
* the last known swap response.
|
|
415
|
-
*
|
|
416
|
-
* @param id - The UUID of the swap.
|
|
417
|
-
* @returns The stored swap data, or null if not found.
|
|
418
|
-
*
|
|
419
|
-
* @example
|
|
420
|
-
* ```ts
|
|
421
|
-
* const stored = await client.getStoredSwap(swapId);
|
|
422
|
-
* if (stored) {
|
|
423
|
-
* console.log("Target:", stored.response.target_token);
|
|
424
|
-
* console.log("Status:", stored.response.status);
|
|
425
|
-
* }
|
|
426
|
-
* ```
|
|
427
|
-
*/
|
|
428
|
-
getStoredSwap(id: string): Promise<StoredSwap | null>;
|
|
429
|
-
/**
|
|
430
|
-
* Gets all stored swaps from local storage.
|
|
431
|
-
*
|
|
432
|
-
* @returns Array of all stored swap data, or empty array if no storage is configured.
|
|
433
|
-
*/
|
|
434
|
-
listAllSwaps(): Promise<StoredSwap[]>;
|
|
435
|
-
deleteSwap(id: string): Promise<void>;
|
|
436
|
-
clearSwapStorage(): Promise<void>;
|
|
437
|
-
/**
|
|
438
|
-
* Recovers all swaps associated with the current wallet from the server.
|
|
439
|
-
*
|
|
440
|
-
* Sends the user's xpub to the server, which returns all swaps belonging
|
|
441
|
-
* to that wallet. For each recovered swap, re-derives the keys using the
|
|
442
|
-
* swap's derivation index and stores it locally.
|
|
443
|
-
*
|
|
444
|
-
* After recovery, the key index is set to `highest_index + 1` so that
|
|
445
|
-
* new swaps don't reuse derivation indices.
|
|
446
|
-
*
|
|
447
|
-
* @returns The recovered swaps stored locally.
|
|
448
|
-
*/
|
|
449
|
-
recoverSwaps(): Promise<StoredSwap[]>;
|
|
450
|
-
/**
|
|
451
|
-
* Gets VHTLC amounts for an Arkade swap.
|
|
452
|
-
*
|
|
453
|
-
* Queries the Arkade indexer for spendable, spent, and recoverable balances
|
|
454
|
-
* at the VHTLC address associated with a swap. Works for:
|
|
455
|
-
* - BTC → EVM swaps where the source asset is Arkade
|
|
456
|
-
* - EVM → BTC swaps where the target asset is Arkade
|
|
457
|
-
*
|
|
458
|
-
* Reads swap data from local storage (does not contact the server).
|
|
459
|
-
*
|
|
460
|
-
* @param id - The UUID of the swap.
|
|
461
|
-
* @returns The VHTLC amounts in satoshis.
|
|
462
|
-
*/
|
|
463
|
-
amountsForSwap(id: string): Promise<VhtlcAmounts>;
|
|
464
|
-
/**
|
|
465
|
-
* Claims a swap by revealing the preimage.
|
|
466
|
-
*
|
|
467
|
-
* Reads swap data and preimage from local storage. The claim method
|
|
468
|
-
* depends on the swap direction and target chain:
|
|
469
|
-
* - **Arkade/Lightning-to-EVM**: Gasless claim via server
|
|
470
|
-
* - **Other EVM swaps**: Returns call data for manual claiming
|
|
471
|
-
* - **Arkade**: Claims via Arkade protocol
|
|
472
|
-
*
|
|
473
|
-
* @param id - The UUID of the swap.
|
|
474
|
-
* @param _options - Deprecated. For Arkade/Lightning-to-EVM, destination is set at swap creation.
|
|
475
|
-
* @returns A ClaimResult with the outcome.
|
|
476
|
-
*
|
|
477
|
-
* @example
|
|
478
|
-
* ```ts
|
|
479
|
-
* // Arkade-to-EVM (gasless via server, uses stored target address)
|
|
480
|
-
* const result = await client.claim(swapId);
|
|
481
|
-
*
|
|
482
|
-
* // Other swap types
|
|
483
|
-
* const result = await client.claim(swapId);
|
|
484
|
-
* if (result.success) {
|
|
485
|
-
* console.log("Claim TX:", result.txHash);
|
|
486
|
-
* }
|
|
487
|
-
* ```
|
|
488
|
-
*/
|
|
489
|
-
claim(id: string, _options?: ClaimOptions): Promise<ClaimResult>;
|
|
490
|
-
/**
|
|
491
|
-
* Claims an Arkade-to-EVM swap gaslessly via the server.
|
|
492
|
-
*
|
|
493
|
-
* The SDK builds the EIP-712 digest, signs it with the swap's internally
|
|
494
|
-
* derived EVM key, and sends the signature + secret to the server. The
|
|
495
|
-
* server submits the `coordinator.redeemAndExecute` transaction.
|
|
496
|
-
*
|
|
497
|
-
* @param id - The UUID of the swap.
|
|
498
|
-
* @param destination - The EVM address where tokens should be sent.
|
|
499
|
-
* @returns The gasless claim result with transaction hash.
|
|
500
|
-
*
|
|
501
|
-
* @example
|
|
502
|
-
* ```ts
|
|
503
|
-
* const result = await client.claimViaGasless(swapId, "0xYourAddress");
|
|
504
|
-
* console.log("Claimed! TX:", result.txHash);
|
|
505
|
-
* ```
|
|
506
|
-
*/
|
|
507
|
-
claimViaGasless(id: string, destination: string, options?: {
|
|
508
|
-
slippage?: number;
|
|
509
|
-
}): Promise<ClaimGaslessResult>;
|
|
510
|
-
/**
|
|
511
|
-
* Claims an Arkade (off-chain) VHTLC swap by revealing the preimage.
|
|
512
|
-
*
|
|
513
|
-
* Automatically selects the best claim method based on VTXO status:
|
|
514
|
-
* - **spendable** VTXOs → offchain spend (submitTx/finalizeTx)
|
|
515
|
-
* - **recoverable** or **mixed** VTXOs → delegated settlement via backend
|
|
516
|
-
*
|
|
517
|
-
* This is used for EVM-to-Arkade and BTC-to-Arkade swaps where the user
|
|
518
|
-
* claims BTC on Arkade after the server has funded the VHTLC.
|
|
519
|
-
*
|
|
520
|
-
* @param id - The UUID of the swap.
|
|
521
|
-
* @param options - Claim options including destination address.
|
|
522
|
-
* @returns The claim result with transaction ID and amount.
|
|
523
|
-
*
|
|
524
|
-
* @example
|
|
525
|
-
* ```ts
|
|
526
|
-
* const result = await client.claimArkade(swapId, {
|
|
527
|
-
* destinationAddress: "ark1q...", // Where to receive BTC
|
|
528
|
-
* });
|
|
529
|
-
* if (result.success) {
|
|
530
|
-
* console.log("Claim TX:", result.txId);
|
|
531
|
-
* console.log("Amount:", result.claimAmount);
|
|
532
|
-
* }
|
|
533
|
-
* ```
|
|
534
|
-
*/
|
|
535
|
-
claimArkade(id: string, options: ArkadeClaimOptions): Promise<{
|
|
536
|
-
success: boolean;
|
|
537
|
-
message: string;
|
|
538
|
-
txId?: string;
|
|
539
|
-
claimAmount?: bigint;
|
|
540
|
-
}>;
|
|
541
|
-
/**
|
|
542
|
-
* Attempts to refund a swap.
|
|
543
|
-
*
|
|
544
|
-
* Refund behavior depends on the swap type:
|
|
545
|
-
* - **Lightning to EVM**: Cannot refund - Lightning swaps auto-expire if not completed.
|
|
546
|
-
* The invoice will simply expire and no funds are locked.
|
|
547
|
-
* - **Arkade to EVM**: Off-chain refund via Arkade server
|
|
548
|
-
* - **Bitcoin (on-chain) to EVM**: Builds a signed refund transaction that the user
|
|
549
|
-
* must broadcast to reclaim their funds after the locktime.
|
|
550
|
-
*
|
|
551
|
-
* @param id - The UUID of the swap to refund.
|
|
552
|
-
* @param options - Options for on-chain refunds (required for btc_onchain swaps).
|
|
553
|
-
* @returns A RefundResult with the transaction details (for on-chain) or status message.
|
|
554
|
-
* @throws Error if the swap cannot be found, storage is not configured, or params are invalid.
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```ts
|
|
558
|
-
* // For on-chain swaps
|
|
559
|
-
* const result = await client.refundSwap(swapId, {
|
|
560
|
-
* destinationAddress: "bc1q...",
|
|
561
|
-
* feeRateSatPerVb: 5,
|
|
562
|
-
* });
|
|
563
|
-
* if (result.success) {
|
|
564
|
-
* console.log("Broadcast this transaction:", result.txHex);
|
|
565
|
-
* console.log("Transaction ID:", result.txId);
|
|
566
|
-
* }
|
|
567
|
-
* ```
|
|
568
|
-
*/
|
|
569
|
-
refundSwap(id: string, options?: RefundOptions): Promise<RefundResult>;
|
|
570
|
-
/**
|
|
571
|
-
* Creates a swap by routing to the correct direction-specific method
|
|
572
|
-
* based on `sourceAsset.chain` and `targetAsset.chain`.
|
|
573
|
-
*
|
|
574
|
-
* Supported directions:
|
|
575
|
-
* - Arkade → EVM
|
|
576
|
-
* - Lightning → EVM
|
|
577
|
-
* - Bitcoin (on-chain) → EVM
|
|
578
|
-
* - Bitcoin (on-chain) → Arkade
|
|
579
|
-
* - EVM → Arkade
|
|
580
|
-
* - EVM → Bitcoin (on-chain)
|
|
581
|
-
* - EVM → Lightning
|
|
582
|
-
*
|
|
583
|
-
* @param options - The swap options including source/target assets, amounts, and addresses.
|
|
584
|
-
* @returns The swap result (response + swapParams).
|
|
585
|
-
* @throws Error if the swap direction is unsupported or required fields are missing.
|
|
586
|
-
*/
|
|
587
|
-
createSwap(options: CreateSwapOptions): Promise<CreateSwapResult>;
|
|
588
|
-
/**
|
|
589
|
-
* Creates a new Arkade-to-EVM swap via the generic chain-agnostic endpoint.
|
|
590
|
-
*
|
|
591
|
-
* Uses the `/swap/arkade/evm` endpoint which supports any ERC-20 token
|
|
592
|
-
* reachable through 1inch aggregation. Returns coordinator address and
|
|
593
|
-
* optional 1inch calldata for the redeem-and-swap flow.
|
|
594
|
-
*
|
|
595
|
-
* @param options - The swap options.
|
|
596
|
-
* @returns The swap response and parameters for storage.
|
|
597
|
-
* @throws Error if the swap creation fails.
|
|
598
|
-
*
|
|
599
|
-
* @example
|
|
600
|
-
* ```ts
|
|
601
|
-
* const result = await client.createArkadeToEvmSwapGeneric({
|
|
602
|
-
* targetAddress: "0x1234...",
|
|
603
|
-
* tokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon
|
|
604
|
-
* evmChainId: 137,
|
|
605
|
-
* sourceAmount: 100000, // 100k sats
|
|
606
|
-
* });
|
|
607
|
-
* console.log("Fund:", result.response.btc_vhtlc_address);
|
|
608
|
-
* console.log("Coordinator:", result.response.evm_coordinator_address);
|
|
609
|
-
* ```
|
|
610
|
-
*/
|
|
611
|
-
createArkadeToEvmSwapGeneric(options: ArkadeToEvmSwapOptions): Promise<ArkadeToEvmSwapResult>;
|
|
612
|
-
/**
|
|
613
|
-
* Creates a new Lightning to EVM swap using the generic chain-agnostic endpoint.
|
|
614
|
-
*
|
|
615
|
-
* @param options - The swap options including evmChainId and tokenAddress.
|
|
616
|
-
* @returns The swap response and parameters for storage.
|
|
617
|
-
*/
|
|
618
|
-
createLightningToEvmSwapGeneric(options: LightningToEvmSwapGenericOptions): Promise<LightningToEvmSwapGenericResult>;
|
|
619
|
-
/**
|
|
620
|
-
* Creates a new Bitcoin (on-chain) to EVM swap.
|
|
621
|
-
*
|
|
622
|
-
* Automatically derives swap parameters and increments the key index.
|
|
623
|
-
*
|
|
624
|
-
* @param options - The swap options.
|
|
625
|
-
* @returns The swap response and parameters for storage.
|
|
626
|
-
* @throws Error if the swap creation fails.
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```ts
|
|
630
|
-
* const result = await client.createBitcoinToEvmSwap({
|
|
631
|
-
* targetAddress: "0x1234...",
|
|
632
|
-
* tokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon
|
|
633
|
-
* evmChainId: 137,
|
|
634
|
-
* sourceAmount: 100000, // 100k sats
|
|
635
|
-
* });
|
|
636
|
-
* console.log("Send BTC to:", result.response.btc_htlc_address);
|
|
637
|
-
* ```
|
|
638
|
-
*/
|
|
639
|
-
createBitcoinToEvmSwap(options: BitcoinToEvmSwapOptions): Promise<BitcoinToEvmSwapResult>;
|
|
640
|
-
/**
|
|
641
|
-
* Creates a new Bitcoin (on-chain) to Arkade swap.
|
|
642
|
-
*
|
|
643
|
-
* The user sends on-chain BTC to a Taproot HTLC address and receives
|
|
644
|
-
* Arkade VTXOs after the server funds the Arkade VHTLC.
|
|
645
|
-
*
|
|
646
|
-
* Automatically derives swap parameters and increments the key index.
|
|
647
|
-
*
|
|
648
|
-
* @param options - The swap options.
|
|
649
|
-
* @returns The swap response and parameters for storage.
|
|
650
|
-
* @throws Error if the swap creation fails.
|
|
651
|
-
*
|
|
652
|
-
* @example
|
|
653
|
-
* ```ts
|
|
654
|
-
* const result = await client.createBitcoinToArkadeSwap({
|
|
655
|
-
* satsReceive: 100000, // 100k sats to receive on Arkade
|
|
656
|
-
* targetAddress: "ark1q...", // Arkade address
|
|
657
|
-
* });
|
|
658
|
-
* console.log("Send BTC to:", result.response.btc_htlc_address);
|
|
659
|
-
* console.log("Amount to send:", result.response.source_amount, "sats");
|
|
660
|
-
* ```
|
|
661
|
-
*/
|
|
662
|
-
createBitcoinToArkadeSwap(options: BitcoinToArkadeSwapOptions): Promise<BitcoinToArkadeSwapResult>;
|
|
663
|
-
/**
|
|
664
|
-
* Creates a new EVM-to-Arkade swap via the generic endpoint.
|
|
665
|
-
*
|
|
666
|
-
* Uses the chain-agnostic `/swap/evm/arkade` endpoint which supports any
|
|
667
|
-
* ERC-20 token reachable through 1inch aggregation.
|
|
668
|
-
*
|
|
669
|
-
* @param options - The swap options.
|
|
670
|
-
* @returns The swap response and parameters for storage.
|
|
671
|
-
* @throws Error if the swap creation fails.
|
|
672
|
-
*
|
|
673
|
-
* @example
|
|
674
|
-
* ```ts
|
|
675
|
-
* const result = await client.createEvmToArkadeSwapGeneric({
|
|
676
|
-
* targetAddress: "ark1q...",
|
|
677
|
-
* tokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon
|
|
678
|
-
* evmChainId: 137,
|
|
679
|
-
* userAddress: "0x1234...",
|
|
680
|
-
* sourceAmount: 100000000, // 100 USDC (6 decimals)
|
|
681
|
-
* });
|
|
682
|
-
* console.log("HTLC:", result.response.evm_htlc_address);
|
|
683
|
-
* ```
|
|
684
|
-
*/
|
|
685
|
-
createEvmToArkadeSwapGeneric(options: EvmToArkadeSwapGenericOptions): Promise<EvmToArkadeSwapGenericResult>;
|
|
686
|
-
/**
|
|
687
|
-
* Creates a new EVM-to-Bitcoin (on-chain) swap.
|
|
688
|
-
*
|
|
689
|
-
* Uses the chain-agnostic `/swap/evm/bitcoin` endpoint which supports any
|
|
690
|
-
* ERC-20 token reachable through 1inch aggregation. The user locks tokens
|
|
691
|
-
* in an EVM HTLC and receives BTC to an on-chain Taproot HTLC.
|
|
692
|
-
*
|
|
693
|
-
* @param options - The swap options.
|
|
694
|
-
* @returns The swap response and parameters for storage.
|
|
695
|
-
* @throws Error if the swap creation fails.
|
|
696
|
-
*
|
|
697
|
-
* @example
|
|
698
|
-
* ```ts
|
|
699
|
-
* const result = await client.createEvmToBitcoinSwap({
|
|
700
|
-
* tokenAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", // USDC on Polygon
|
|
701
|
-
* evmChainId: 137,
|
|
702
|
-
* userAddress: "0x1234...",
|
|
703
|
-
* sourceAmount: 100000000n, // 100 USDC (6 decimals)
|
|
704
|
-
* });
|
|
705
|
-
* console.log("EVM HTLC:", result.response.evm_htlc_address);
|
|
706
|
-
* console.log("BTC HTLC:", result.response.btc_htlc_address);
|
|
707
|
-
* ```
|
|
708
|
-
*/
|
|
709
|
-
createEvmToBitcoinSwap(options: EvmToBitcoinSwapOptions): Promise<EvmToBitcoinSwapResult>;
|
|
710
|
-
/**
|
|
711
|
-
* Creates a new EVM to Lightning swap using the chain-agnostic generic endpoint.
|
|
712
|
-
*
|
|
713
|
-
* This allows users to swap any ERC-20 token from any supported EVM chain
|
|
714
|
-
* to pay a Lightning invoice.
|
|
715
|
-
*
|
|
716
|
-
* @param options - The swap options including Lightning invoice, chain ID, and token address.
|
|
717
|
-
* @returns The swap response and parameters for storage.
|
|
718
|
-
* @throws Error if the swap creation fails.
|
|
719
|
-
*
|
|
720
|
-
* @example
|
|
721
|
-
* ```ts
|
|
722
|
-
* const result = await client.createEvmToLightningSwapGeneric({
|
|
723
|
-
* lightningInvoice: "lnbc...",
|
|
724
|
-
* evmChainId: 137, // Polygon
|
|
725
|
-
* tokenAddress: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", // WBTC
|
|
726
|
-
* userAddress: "0x1234...",
|
|
727
|
-
* });
|
|
728
|
-
* console.log("HTLC contract:", result.response.evm_htlc_address);
|
|
729
|
-
* console.log("Swap ID:", result.response.id);
|
|
730
|
-
* ```
|
|
731
|
-
*/
|
|
732
|
-
createEvmToLightningSwapGeneric(options: EvmToLightningSwapGenericOptions): Promise<EvmToLightningSwapGenericResult>;
|
|
733
|
-
/**
|
|
734
|
-
* Gets call data to fund an EVM-to-BTC swap via the HTLCCoordinator.
|
|
735
|
-
*
|
|
736
|
-
* The coordinator atomically swaps source tokens (e.g. USDC) to WBTC via DEX
|
|
737
|
-
* and locks the WBTC into an HTLC in a single transaction.
|
|
738
|
-
*
|
|
739
|
-
* Fetches the coordinator calldata from the server, which builds the 1inch
|
|
740
|
-
* swap calldata and computes the refundCallsHash.
|
|
741
|
-
*
|
|
742
|
-
* @param swapId - The UUID of the swap.
|
|
743
|
-
* @param approveMax - If true, approves max uint256. If false, approves exact amount. Default: true.
|
|
744
|
-
* @returns The approve and executeAndCreate call data.
|
|
745
|
-
*
|
|
746
|
-
* @example
|
|
747
|
-
* ```ts
|
|
748
|
-
* const swap = await client.createEvmToArkadeSwap({...});
|
|
749
|
-
* const funding = await client.getCoordinatorFundingCallData(swap.response.id);
|
|
750
|
-
*
|
|
751
|
-
* // Step 1: Approve source token to coordinator
|
|
752
|
-
* await wallet.sendTransaction({ to: funding.approve.to, data: funding.approve.data });
|
|
753
|
-
*
|
|
754
|
-
* // Step 2: Execute swap + create HTLC
|
|
755
|
-
* await wallet.sendTransaction({ to: funding.executeAndCreate.to, data: funding.executeAndCreate.data });
|
|
756
|
-
* ```
|
|
757
|
-
*/
|
|
758
|
-
getCoordinatorFundingCallData(swapId: string, approveMax?: boolean): Promise<CoordinatorFundingCallData>;
|
|
759
|
-
}
|
|
760
|
-
//# sourceMappingURL=client.d.ts.map
|