@stablechain/sdk 1.0.2 → 1.0.3
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 +438 -14
- package/dist/index.d.cts +71 -2
- package/dist/index.d.ts +71 -2
- package/dist/index.js +455 -31
- 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.
|
|
@@ -145,6 +152,21 @@ interface EarnResult {
|
|
|
145
152
|
txHash: string;
|
|
146
153
|
idempotencyKey?: string;
|
|
147
154
|
}
|
|
155
|
+
interface EarnDepositCalldata {
|
|
156
|
+
/** Ordered transactions to send: optional token approval followed by the deposit */
|
|
157
|
+
steps: Array<{
|
|
158
|
+
to: string;
|
|
159
|
+
data: string;
|
|
160
|
+
value: bigint;
|
|
161
|
+
}>;
|
|
162
|
+
chainId: number;
|
|
163
|
+
}
|
|
164
|
+
interface EarnWithdrawCalldata {
|
|
165
|
+
to: string;
|
|
166
|
+
data: string;
|
|
167
|
+
value: bigint;
|
|
168
|
+
chainId: number;
|
|
169
|
+
}
|
|
148
170
|
type BulkEarnResultItem = {
|
|
149
171
|
status: "fulfilled";
|
|
150
172
|
txHash: string;
|
|
@@ -221,6 +243,38 @@ interface ForceRedeemParams {
|
|
|
221
243
|
/** Deduplication key */
|
|
222
244
|
idempotencyKey?: string;
|
|
223
245
|
}
|
|
246
|
+
interface MerklRewardToken {
|
|
247
|
+
address: string;
|
|
248
|
+
symbol: string;
|
|
249
|
+
decimals: number;
|
|
250
|
+
}
|
|
251
|
+
interface MerklReward {
|
|
252
|
+
token: MerklRewardToken;
|
|
253
|
+
/** Raw cumulative claimable amount as a string (pass to BigInt for contract args) */
|
|
254
|
+
rawAmount: string;
|
|
255
|
+
/** Human-readable cumulative claimable amount */
|
|
256
|
+
amount: number;
|
|
257
|
+
/** Merkle proofs required for on-chain claiming */
|
|
258
|
+
proofs: string[];
|
|
259
|
+
}
|
|
260
|
+
interface MerklRewardsResult {
|
|
261
|
+
chainId: number;
|
|
262
|
+
rewards: MerklReward[];
|
|
263
|
+
}
|
|
264
|
+
interface MerklClaimResult {
|
|
265
|
+
txHash: string;
|
|
266
|
+
/** Number of distinct reward tokens claimed */
|
|
267
|
+
tokenCount: number;
|
|
268
|
+
}
|
|
269
|
+
interface MerklClaimCalldata {
|
|
270
|
+
/** Distributor contract to send the transaction to */
|
|
271
|
+
to: string;
|
|
272
|
+
/** ABI-encoded calldata for the claim function */
|
|
273
|
+
data: string;
|
|
274
|
+
chainId: number;
|
|
275
|
+
/** Rewards included in this calldata */
|
|
276
|
+
rewards: MerklReward[];
|
|
277
|
+
}
|
|
224
278
|
interface VaultYieldReward {
|
|
225
279
|
/** Reward token symbol (e.g. "MORPHO") */
|
|
226
280
|
symbol: string;
|
|
@@ -278,6 +332,8 @@ interface StableReaderConfig {
|
|
|
278
332
|
earn?: EarnConfig;
|
|
279
333
|
/** Address of the user whose position to read */
|
|
280
334
|
address: string;
|
|
335
|
+
/** Base URL for the Merkl rewards API — see StableConfig.merklApiBase */
|
|
336
|
+
merklApiBase?: string;
|
|
281
337
|
}
|
|
282
338
|
|
|
283
339
|
interface StableClient {
|
|
@@ -294,6 +350,15 @@ interface StableClient {
|
|
|
294
350
|
redeem(params: EarnRedeemParams): Promise<EarnResult>;
|
|
295
351
|
forceWithdraw(params: ForceWithdrawParams): Promise<EarnResult>;
|
|
296
352
|
forceRedeem(params: ForceRedeemParams): Promise<EarnResult>;
|
|
353
|
+
prepareDepositCalldata(params: EarnDepositParams): Promise<EarnDepositCalldata>;
|
|
354
|
+
prepareWithdrawCalldata(params: EarnWithdrawParams): Promise<EarnWithdrawCalldata>;
|
|
355
|
+
prepareRedeemCalldata(params: EarnRedeemParams): Promise<EarnWithdrawCalldata>;
|
|
356
|
+
incentiveRewards: {
|
|
357
|
+
/** Fetch pending Merkl rewards for the signer's address on the configured chain. */
|
|
358
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
359
|
+
/** Claim all pending Merkl rewards for the signer on the configured chain. */
|
|
360
|
+
claim(): Promise<MerklClaimResult>;
|
|
361
|
+
};
|
|
297
362
|
};
|
|
298
363
|
}
|
|
299
364
|
interface StableReader {
|
|
@@ -312,9 +377,13 @@ interface StableReader {
|
|
|
312
377
|
amount: number;
|
|
313
378
|
tokenDecimals?: number;
|
|
314
379
|
}): Promise<WithdrawStatus>;
|
|
380
|
+
incentiveRewards: {
|
|
381
|
+
/** Fetch pending Merkl rewards for the configured address on the configured chain. */
|
|
382
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
383
|
+
};
|
|
315
384
|
};
|
|
316
385
|
}
|
|
317
|
-
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, }: StableConfig): StableClient;
|
|
386
|
+
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, merklApiBase, }: StableConfig): StableClient;
|
|
318
387
|
declare function createStableReader(config: StableReaderConfig): StableReader;
|
|
319
388
|
|
|
320
389
|
interface ChainConfig {
|
|
@@ -386,4 +455,4 @@ declare class StableBulkError extends StableError {
|
|
|
386
455
|
});
|
|
387
456
|
}
|
|
388
457
|
|
|
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 };
|
|
458
|
+
export { type BridgeParams, type BridgeQuote, 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.
|
|
@@ -145,6 +152,21 @@ interface EarnResult {
|
|
|
145
152
|
txHash: string;
|
|
146
153
|
idempotencyKey?: string;
|
|
147
154
|
}
|
|
155
|
+
interface EarnDepositCalldata {
|
|
156
|
+
/** Ordered transactions to send: optional token approval followed by the deposit */
|
|
157
|
+
steps: Array<{
|
|
158
|
+
to: string;
|
|
159
|
+
data: string;
|
|
160
|
+
value: bigint;
|
|
161
|
+
}>;
|
|
162
|
+
chainId: number;
|
|
163
|
+
}
|
|
164
|
+
interface EarnWithdrawCalldata {
|
|
165
|
+
to: string;
|
|
166
|
+
data: string;
|
|
167
|
+
value: bigint;
|
|
168
|
+
chainId: number;
|
|
169
|
+
}
|
|
148
170
|
type BulkEarnResultItem = {
|
|
149
171
|
status: "fulfilled";
|
|
150
172
|
txHash: string;
|
|
@@ -221,6 +243,38 @@ interface ForceRedeemParams {
|
|
|
221
243
|
/** Deduplication key */
|
|
222
244
|
idempotencyKey?: string;
|
|
223
245
|
}
|
|
246
|
+
interface MerklRewardToken {
|
|
247
|
+
address: string;
|
|
248
|
+
symbol: string;
|
|
249
|
+
decimals: number;
|
|
250
|
+
}
|
|
251
|
+
interface MerklReward {
|
|
252
|
+
token: MerklRewardToken;
|
|
253
|
+
/** Raw cumulative claimable amount as a string (pass to BigInt for contract args) */
|
|
254
|
+
rawAmount: string;
|
|
255
|
+
/** Human-readable cumulative claimable amount */
|
|
256
|
+
amount: number;
|
|
257
|
+
/** Merkle proofs required for on-chain claiming */
|
|
258
|
+
proofs: string[];
|
|
259
|
+
}
|
|
260
|
+
interface MerklRewardsResult {
|
|
261
|
+
chainId: number;
|
|
262
|
+
rewards: MerklReward[];
|
|
263
|
+
}
|
|
264
|
+
interface MerklClaimResult {
|
|
265
|
+
txHash: string;
|
|
266
|
+
/** Number of distinct reward tokens claimed */
|
|
267
|
+
tokenCount: number;
|
|
268
|
+
}
|
|
269
|
+
interface MerklClaimCalldata {
|
|
270
|
+
/** Distributor contract to send the transaction to */
|
|
271
|
+
to: string;
|
|
272
|
+
/** ABI-encoded calldata for the claim function */
|
|
273
|
+
data: string;
|
|
274
|
+
chainId: number;
|
|
275
|
+
/** Rewards included in this calldata */
|
|
276
|
+
rewards: MerklReward[];
|
|
277
|
+
}
|
|
224
278
|
interface VaultYieldReward {
|
|
225
279
|
/** Reward token symbol (e.g. "MORPHO") */
|
|
226
280
|
symbol: string;
|
|
@@ -278,6 +332,8 @@ interface StableReaderConfig {
|
|
|
278
332
|
earn?: EarnConfig;
|
|
279
333
|
/** Address of the user whose position to read */
|
|
280
334
|
address: string;
|
|
335
|
+
/** Base URL for the Merkl rewards API — see StableConfig.merklApiBase */
|
|
336
|
+
merklApiBase?: string;
|
|
281
337
|
}
|
|
282
338
|
|
|
283
339
|
interface StableClient {
|
|
@@ -294,6 +350,15 @@ interface StableClient {
|
|
|
294
350
|
redeem(params: EarnRedeemParams): Promise<EarnResult>;
|
|
295
351
|
forceWithdraw(params: ForceWithdrawParams): Promise<EarnResult>;
|
|
296
352
|
forceRedeem(params: ForceRedeemParams): Promise<EarnResult>;
|
|
353
|
+
prepareDepositCalldata(params: EarnDepositParams): Promise<EarnDepositCalldata>;
|
|
354
|
+
prepareWithdrawCalldata(params: EarnWithdrawParams): Promise<EarnWithdrawCalldata>;
|
|
355
|
+
prepareRedeemCalldata(params: EarnRedeemParams): Promise<EarnWithdrawCalldata>;
|
|
356
|
+
incentiveRewards: {
|
|
357
|
+
/** Fetch pending Merkl rewards for the signer's address on the configured chain. */
|
|
358
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
359
|
+
/** Claim all pending Merkl rewards for the signer on the configured chain. */
|
|
360
|
+
claim(): Promise<MerklClaimResult>;
|
|
361
|
+
};
|
|
297
362
|
};
|
|
298
363
|
}
|
|
299
364
|
interface StableReader {
|
|
@@ -312,9 +377,13 @@ interface StableReader {
|
|
|
312
377
|
amount: number;
|
|
313
378
|
tokenDecimals?: number;
|
|
314
379
|
}): Promise<WithdrawStatus>;
|
|
380
|
+
incentiveRewards: {
|
|
381
|
+
/** Fetch pending Merkl rewards for the configured address on the configured chain. */
|
|
382
|
+
fetch(): Promise<MerklRewardsResult>;
|
|
383
|
+
};
|
|
315
384
|
};
|
|
316
385
|
}
|
|
317
|
-
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, }: StableConfig): StableClient;
|
|
386
|
+
declare function createStable({ network, rpc: rpcOverride, account, transport, walletClient, earn: earnConfig, merklApiBase, }: StableConfig): StableClient;
|
|
318
387
|
declare function createStableReader(config: StableReaderConfig): StableReader;
|
|
319
388
|
|
|
320
389
|
interface ChainConfig {
|
|
@@ -386,4 +455,4 @@ declare class StableBulkError extends StableError {
|
|
|
386
455
|
});
|
|
387
456
|
}
|
|
388
457
|
|
|
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 };
|
|
458
|
+
export { type BridgeParams, type BridgeQuote, 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 };
|