@stablechain/sdk 1.0.2 → 1.0.4
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/index.cjs +753 -30
- package/dist/index.d.cts +98 -2
- package/dist/index.d.ts +98 -2
- package/dist/index.js +775 -52
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -17,6 +17,13 @@ interface StableConfig {
|
|
|
17
17
|
walletClient?: WalletClient;
|
|
18
18
|
/** Earn (Morpho V2 vault) configuration — required to use stable.earn.* methods. */
|
|
19
19
|
earn?: EarnConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Base URL for the Merkl rewards API (default: https://api.merkl.xyz).
|
|
22
|
+
* Override when calling from a browser to proxy through your own server and
|
|
23
|
+
* avoid CORS restrictions — Merkl does not send Access-Control-Allow-Origin
|
|
24
|
+
* headers for all chains.
|
|
25
|
+
*/
|
|
26
|
+
merklApiBase?: string;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Unified result for transfer, bridge, and swap.
|
|
@@ -88,7 +95,20 @@ declare enum Network {
|
|
|
88
95
|
interface BridgeQuote {
|
|
89
96
|
/** Estimated output amount on the destination chain */
|
|
90
97
|
toAmount?: number;
|
|
98
|
+
/** LayerZero native messaging fee (wei) — only present for USDT0→USDT0 (OFT) routes */
|
|
99
|
+
nativeFee?: bigint;
|
|
100
|
+
/** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
|
|
101
|
+
lzTokenFee?: bigint;
|
|
91
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Bridge route selection:
|
|
105
|
+
* - `"usdt0"` — force the USDT0 LayerZero OFT path (no protocol fee, just gas + LZ
|
|
106
|
+
* messaging fee; slower). Throws if the chain pair has no USDT0 adapter.
|
|
107
|
+
* - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
|
|
108
|
+
* - `"auto"` — use USDT0 when both chains support it and tokens match, else LI.FI.
|
|
109
|
+
* This is the default.
|
|
110
|
+
*/
|
|
111
|
+
type BridgeRoute = "auto" | "usdt0" | "lifi";
|
|
92
112
|
interface BridgeParams {
|
|
93
113
|
fromChain: Chain;
|
|
94
114
|
toChain: Chain;
|
|
@@ -101,6 +121,11 @@ interface BridgeParams {
|
|
|
101
121
|
fromDecimals?: number;
|
|
102
122
|
/** Recipient address — defaults to the signer */
|
|
103
123
|
recipient?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Which bridge to use. Defaults to "auto" (USDT0 OFT when available, else LI.FI).
|
|
126
|
+
* See {@link BridgeRoute}.
|
|
127
|
+
*/
|
|
128
|
+
route?: BridgeRoute;
|
|
104
129
|
/** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
|
|
105
130
|
quote?: BridgeQuote;
|
|
106
131
|
}
|
|
@@ -145,6 +170,21 @@ interface EarnResult {
|
|
|
145
170
|
txHash: string;
|
|
146
171
|
idempotencyKey?: string;
|
|
147
172
|
}
|
|
173
|
+
interface EarnDepositCalldata {
|
|
174
|
+
/** Ordered transactions to send: optional token approval followed by the deposit */
|
|
175
|
+
steps: Array<{
|
|
176
|
+
to: string;
|
|
177
|
+
data: string;
|
|
178
|
+
value: bigint;
|
|
179
|
+
}>;
|
|
180
|
+
chainId: number;
|
|
181
|
+
}
|
|
182
|
+
interface EarnWithdrawCalldata {
|
|
183
|
+
to: string;
|
|
184
|
+
data: string;
|
|
185
|
+
value: bigint;
|
|
186
|
+
chainId: number;
|
|
187
|
+
}
|
|
148
188
|
type BulkEarnResultItem = {
|
|
149
189
|
status: "fulfilled";
|
|
150
190
|
txHash: string;
|
|
@@ -221,6 +261,38 @@ interface ForceRedeemParams {
|
|
|
221
261
|
/** Deduplication key */
|
|
222
262
|
idempotencyKey?: string;
|
|
223
263
|
}
|
|
264
|
+
interface MerklRewardToken {
|
|
265
|
+
address: string;
|
|
266
|
+
symbol: string;
|
|
267
|
+
decimals: number;
|
|
268
|
+
}
|
|
269
|
+
interface MerklReward {
|
|
270
|
+
token: MerklRewardToken;
|
|
271
|
+
/** Raw cumulative claimable amount as a string (pass to BigInt for contract args) */
|
|
272
|
+
rawAmount: string;
|
|
273
|
+
/** Human-readable cumulative claimable amount */
|
|
274
|
+
amount: number;
|
|
275
|
+
/** Merkle proofs required for on-chain claiming */
|
|
276
|
+
proofs: string[];
|
|
277
|
+
}
|
|
278
|
+
interface MerklRewardsResult {
|
|
279
|
+
chainId: number;
|
|
280
|
+
rewards: MerklReward[];
|
|
281
|
+
}
|
|
282
|
+
interface MerklClaimResult {
|
|
283
|
+
txHash: string;
|
|
284
|
+
/** Number of distinct reward tokens claimed */
|
|
285
|
+
tokenCount: number;
|
|
286
|
+
}
|
|
287
|
+
interface MerklClaimCalldata {
|
|
288
|
+
/** Distributor contract to send the transaction to */
|
|
289
|
+
to: string;
|
|
290
|
+
/** ABI-encoded calldata for the claim function */
|
|
291
|
+
data: string;
|
|
292
|
+
chainId: number;
|
|
293
|
+
/** Rewards included in this calldata */
|
|
294
|
+
rewards: MerklReward[];
|
|
295
|
+
}
|
|
224
296
|
interface VaultYieldReward {
|
|
225
297
|
/** Reward token symbol (e.g. "MORPHO") */
|
|
226
298
|
symbol: string;
|
|
@@ -278,6 +350,8 @@ interface StableReaderConfig {
|
|
|
278
350
|
earn?: EarnConfig;
|
|
279
351
|
/** Address of the user whose position to read */
|
|
280
352
|
address: string;
|
|
353
|
+
/** Base URL for the Merkl rewards API — see StableConfig.merklApiBase */
|
|
354
|
+
merklApiBase?: string;
|
|
281
355
|
}
|
|
282
356
|
|
|
283
357
|
interface StableClient {
|
|
@@ -294,6 +368,15 @@ interface StableClient {
|
|
|
294
368
|
redeem(params: EarnRedeemParams): Promise<EarnResult>;
|
|
295
369
|
forceWithdraw(params: ForceWithdrawParams): Promise<EarnResult>;
|
|
296
370
|
forceRedeem(params: ForceRedeemParams): Promise<EarnResult>;
|
|
371
|
+
prepareDepositCalldata(params: EarnDepositParams): Promise<EarnDepositCalldata>;
|
|
372
|
+
prepareWithdrawCalldata(params: EarnWithdrawParams): Promise<EarnWithdrawCalldata>;
|
|
373
|
+
prepareRedeemCalldata(params: EarnRedeemParams): Promise<EarnWithdrawCalldata>;
|
|
374
|
+
incentiveRewards: {
|
|
375
|
+
/** Fetch pending Merkl rewards for the signer's address on the configured chain. */
|
|
376
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
377
|
+
/** Claim all pending Merkl rewards for the signer on the configured chain. */
|
|
378
|
+
claim(): Promise<MerklClaimResult>;
|
|
379
|
+
};
|
|
297
380
|
};
|
|
298
381
|
}
|
|
299
382
|
interface StableReader {
|
|
@@ -312,9 +395,13 @@ interface StableReader {
|
|
|
312
395
|
amount: number;
|
|
313
396
|
tokenDecimals?: number;
|
|
314
397
|
}): Promise<WithdrawStatus>;
|
|
398
|
+
incentiveRewards: {
|
|
399
|
+
/** Fetch pending Merkl rewards for the configured address on the configured chain. */
|
|
400
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
401
|
+
};
|
|
315
402
|
};
|
|
316
403
|
}
|
|
317
|
-
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, }: StableConfig): StableClient;
|
|
404
|
+
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, merklApiBase, }: StableConfig): StableClient;
|
|
318
405
|
declare function createStableReader(config: StableReaderConfig): StableReader;
|
|
319
406
|
|
|
320
407
|
interface ChainConfig {
|
|
@@ -326,6 +413,15 @@ interface ChainConfig {
|
|
|
326
413
|
}
|
|
327
414
|
declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
|
|
328
415
|
|
|
416
|
+
interface BridgeChainConfig extends ChainConfig {
|
|
417
|
+
lzEid: number;
|
|
418
|
+
/** Only set on source chains that have an OFT Adapter deployed */
|
|
419
|
+
oftAdapter?: Address;
|
|
420
|
+
/** False when the OFT adapter exists but has no outbound send pathways configured */
|
|
421
|
+
lzOutbound?: boolean;
|
|
422
|
+
}
|
|
423
|
+
declare const BRIDGE_CHAIN_CONFIGS: Partial<Record<Chain, BridgeChainConfig>>;
|
|
424
|
+
|
|
329
425
|
declare const STABLE_USDT_ADDRESS: Address;
|
|
330
426
|
declare const STABLE_VAULT_ADDRESS: Address;
|
|
331
427
|
|
|
@@ -386,4 +482,4 @@ declare class StableBulkError extends StableError {
|
|
|
386
482
|
});
|
|
387
483
|
}
|
|
388
484
|
|
|
389
|
-
export { type BridgeParams, type BridgeQuote, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, createStable, createStableReader };
|
|
485
|
+
export { BRIDGE_CHAIN_CONFIGS, type BridgeChainConfig, type BridgeParams, type BridgeQuote, type BridgeRoute, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositCalldata, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawCalldata, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, type MerklClaimCalldata, type MerklClaimResult, type MerklReward, type MerklRewardToken, type MerklRewardsResult, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, createStable, createStableReader };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ interface StableConfig {
|
|
|
17
17
|
walletClient?: WalletClient;
|
|
18
18
|
/** Earn (Morpho V2 vault) configuration — required to use stable.earn.* methods. */
|
|
19
19
|
earn?: EarnConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Base URL for the Merkl rewards API (default: https://api.merkl.xyz).
|
|
22
|
+
* Override when calling from a browser to proxy through your own server and
|
|
23
|
+
* avoid CORS restrictions — Merkl does not send Access-Control-Allow-Origin
|
|
24
|
+
* headers for all chains.
|
|
25
|
+
*/
|
|
26
|
+
merklApiBase?: string;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Unified result for transfer, bridge, and swap.
|
|
@@ -88,7 +95,20 @@ declare enum Network {
|
|
|
88
95
|
interface BridgeQuote {
|
|
89
96
|
/** Estimated output amount on the destination chain */
|
|
90
97
|
toAmount?: number;
|
|
98
|
+
/** LayerZero native messaging fee (wei) — only present for USDT0→USDT0 (OFT) routes */
|
|
99
|
+
nativeFee?: bigint;
|
|
100
|
+
/** LayerZero fee paid in LZ token (wei) — only present for USDT0→USDT0 (OFT) routes */
|
|
101
|
+
lzTokenFee?: bigint;
|
|
91
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Bridge route selection:
|
|
105
|
+
* - `"usdt0"` — force the USDT0 LayerZero OFT path (no protocol fee, just gas + LZ
|
|
106
|
+
* messaging fee; slower). Throws if the chain pair has no USDT0 adapter.
|
|
107
|
+
* - `"lifi"` — force the LI.FI aggregator path (fast, charges a fee).
|
|
108
|
+
* - `"auto"` — use USDT0 when both chains support it and tokens match, else LI.FI.
|
|
109
|
+
* This is the default.
|
|
110
|
+
*/
|
|
111
|
+
type BridgeRoute = "auto" | "usdt0" | "lifi";
|
|
92
112
|
interface BridgeParams {
|
|
93
113
|
fromChain: Chain;
|
|
94
114
|
toChain: Chain;
|
|
@@ -101,6 +121,11 @@ interface BridgeParams {
|
|
|
101
121
|
fromDecimals?: number;
|
|
102
122
|
/** Recipient address — defaults to the signer */
|
|
103
123
|
recipient?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Which bridge to use. Defaults to "auto" (USDT0 OFT when available, else LI.FI).
|
|
126
|
+
* See {@link BridgeRoute}.
|
|
127
|
+
*/
|
|
128
|
+
route?: BridgeRoute;
|
|
104
129
|
/** Pre-fetched quote from quoteBridge() — skips the quote fetch when passed to bridge() */
|
|
105
130
|
quote?: BridgeQuote;
|
|
106
131
|
}
|
|
@@ -145,6 +170,21 @@ interface EarnResult {
|
|
|
145
170
|
txHash: string;
|
|
146
171
|
idempotencyKey?: string;
|
|
147
172
|
}
|
|
173
|
+
interface EarnDepositCalldata {
|
|
174
|
+
/** Ordered transactions to send: optional token approval followed by the deposit */
|
|
175
|
+
steps: Array<{
|
|
176
|
+
to: string;
|
|
177
|
+
data: string;
|
|
178
|
+
value: bigint;
|
|
179
|
+
}>;
|
|
180
|
+
chainId: number;
|
|
181
|
+
}
|
|
182
|
+
interface EarnWithdrawCalldata {
|
|
183
|
+
to: string;
|
|
184
|
+
data: string;
|
|
185
|
+
value: bigint;
|
|
186
|
+
chainId: number;
|
|
187
|
+
}
|
|
148
188
|
type BulkEarnResultItem = {
|
|
149
189
|
status: "fulfilled";
|
|
150
190
|
txHash: string;
|
|
@@ -221,6 +261,38 @@ interface ForceRedeemParams {
|
|
|
221
261
|
/** Deduplication key */
|
|
222
262
|
idempotencyKey?: string;
|
|
223
263
|
}
|
|
264
|
+
interface MerklRewardToken {
|
|
265
|
+
address: string;
|
|
266
|
+
symbol: string;
|
|
267
|
+
decimals: number;
|
|
268
|
+
}
|
|
269
|
+
interface MerklReward {
|
|
270
|
+
token: MerklRewardToken;
|
|
271
|
+
/** Raw cumulative claimable amount as a string (pass to BigInt for contract args) */
|
|
272
|
+
rawAmount: string;
|
|
273
|
+
/** Human-readable cumulative claimable amount */
|
|
274
|
+
amount: number;
|
|
275
|
+
/** Merkle proofs required for on-chain claiming */
|
|
276
|
+
proofs: string[];
|
|
277
|
+
}
|
|
278
|
+
interface MerklRewardsResult {
|
|
279
|
+
chainId: number;
|
|
280
|
+
rewards: MerklReward[];
|
|
281
|
+
}
|
|
282
|
+
interface MerklClaimResult {
|
|
283
|
+
txHash: string;
|
|
284
|
+
/** Number of distinct reward tokens claimed */
|
|
285
|
+
tokenCount: number;
|
|
286
|
+
}
|
|
287
|
+
interface MerklClaimCalldata {
|
|
288
|
+
/** Distributor contract to send the transaction to */
|
|
289
|
+
to: string;
|
|
290
|
+
/** ABI-encoded calldata for the claim function */
|
|
291
|
+
data: string;
|
|
292
|
+
chainId: number;
|
|
293
|
+
/** Rewards included in this calldata */
|
|
294
|
+
rewards: MerklReward[];
|
|
295
|
+
}
|
|
224
296
|
interface VaultYieldReward {
|
|
225
297
|
/** Reward token symbol (e.g. "MORPHO") */
|
|
226
298
|
symbol: string;
|
|
@@ -278,6 +350,8 @@ interface StableReaderConfig {
|
|
|
278
350
|
earn?: EarnConfig;
|
|
279
351
|
/** Address of the user whose position to read */
|
|
280
352
|
address: string;
|
|
353
|
+
/** Base URL for the Merkl rewards API — see StableConfig.merklApiBase */
|
|
354
|
+
merklApiBase?: string;
|
|
281
355
|
}
|
|
282
356
|
|
|
283
357
|
interface StableClient {
|
|
@@ -294,6 +368,15 @@ interface StableClient {
|
|
|
294
368
|
redeem(params: EarnRedeemParams): Promise<EarnResult>;
|
|
295
369
|
forceWithdraw(params: ForceWithdrawParams): Promise<EarnResult>;
|
|
296
370
|
forceRedeem(params: ForceRedeemParams): Promise<EarnResult>;
|
|
371
|
+
prepareDepositCalldata(params: EarnDepositParams): Promise<EarnDepositCalldata>;
|
|
372
|
+
prepareWithdrawCalldata(params: EarnWithdrawParams): Promise<EarnWithdrawCalldata>;
|
|
373
|
+
prepareRedeemCalldata(params: EarnRedeemParams): Promise<EarnWithdrawCalldata>;
|
|
374
|
+
incentiveRewards: {
|
|
375
|
+
/** Fetch pending Merkl rewards for the signer's address on the configured chain. */
|
|
376
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
377
|
+
/** Claim all pending Merkl rewards for the signer on the configured chain. */
|
|
378
|
+
claim(): Promise<MerklClaimResult>;
|
|
379
|
+
};
|
|
297
380
|
};
|
|
298
381
|
}
|
|
299
382
|
interface StableReader {
|
|
@@ -312,9 +395,13 @@ interface StableReader {
|
|
|
312
395
|
amount: number;
|
|
313
396
|
tokenDecimals?: number;
|
|
314
397
|
}): Promise<WithdrawStatus>;
|
|
398
|
+
incentiveRewards: {
|
|
399
|
+
/** Fetch pending Merkl rewards for the configured address on the configured chain. */
|
|
400
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
401
|
+
};
|
|
315
402
|
};
|
|
316
403
|
}
|
|
317
|
-
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, }: StableConfig): StableClient;
|
|
404
|
+
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, merklApiBase, }: StableConfig): StableClient;
|
|
318
405
|
declare function createStableReader(config: StableReaderConfig): StableReader;
|
|
319
406
|
|
|
320
407
|
interface ChainConfig {
|
|
@@ -326,6 +413,15 @@ interface ChainConfig {
|
|
|
326
413
|
}
|
|
327
414
|
declare const CHAIN_CONFIGS: Partial<Record<Chain, ChainConfig>>;
|
|
328
415
|
|
|
416
|
+
interface BridgeChainConfig extends ChainConfig {
|
|
417
|
+
lzEid: number;
|
|
418
|
+
/** Only set on source chains that have an OFT Adapter deployed */
|
|
419
|
+
oftAdapter?: Address;
|
|
420
|
+
/** False when the OFT adapter exists but has no outbound send pathways configured */
|
|
421
|
+
lzOutbound?: boolean;
|
|
422
|
+
}
|
|
423
|
+
declare const BRIDGE_CHAIN_CONFIGS: Partial<Record<Chain, BridgeChainConfig>>;
|
|
424
|
+
|
|
329
425
|
declare const STABLE_USDT_ADDRESS: Address;
|
|
330
426
|
declare const STABLE_VAULT_ADDRESS: Address;
|
|
331
427
|
|
|
@@ -386,4 +482,4 @@ declare class StableBulkError extends StableError {
|
|
|
386
482
|
});
|
|
387
483
|
}
|
|
388
484
|
|
|
389
|
-
export { type BridgeParams, type BridgeQuote, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, createStable, createStableReader };
|
|
485
|
+
export { BRIDGE_CHAIN_CONFIGS, type BridgeChainConfig, type BridgeParams, type BridgeQuote, type BridgeRoute, type BulkDepositOptions, type BulkEarnResult, type BulkEarnResultItem, type BulkWithdrawOptions, CHAIN_CONFIGS, Chain, type ChainConfig, type EarnConfig, type EarnDepositCalldata, type EarnDepositParams, type EarnRedeemParams, type EarnResult, type EarnWithdrawCalldata, type EarnWithdrawParams, type ForceDeallocation, type ForceRedeemParams, type ForceWithdrawParams, type MerklClaimCalldata, type MerklClaimResult, type MerklReward, type MerklRewardToken, type MerklRewardsResult, Network, type OperationResult, STABLE_USDT_ADDRESS, STABLE_VAULT_ADDRESS, StableBulkError, type StableClient, type StableConfig, StableError, StableNetworkError, StableQuoteError, type StableReader, type StableReaderConfig, StableTransactionError, StableValidationError, type SwapParams, type SwapQuote, type TransferParams, type VaultPosition, type VaultYield, type VaultYieldReward, type WithdrawStatus, type YieldPreview, createStable, createStableReader };
|