@zyfai/sdk 0.9.0 → 0.10.0
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/README.md +16 -8
- package/dist/index.d.mts +62 -2
- package/dist/index.d.ts +62 -2
- package/dist/index.js +200 -6
- package/dist/index.mjs +200 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -421,12 +421,13 @@ Transfer tokens to your Safe smart wallet. Token address is automatically select
|
|
|
421
421
|
|
|
422
422
|
- **Ethereum Mainnet (1), Base (8453), Arbitrum (42161)**: USDC (default) or WETH
|
|
423
423
|
- **Ethereum Mainnet (1), Base (8453)**: EURC (6 decimals; not available on Arbitrum)
|
|
424
|
+
- **Ethereum Mainnet (1) only**: USDT and PYUSD (6 decimals)
|
|
424
425
|
- **Base (8453) only**: NVDAc (8 decimals) — tokenized NVIDIA equity, see [Tokenized equities](#tokenized-equities-nvdac)
|
|
425
426
|
|
|
426
427
|
**Minimum portfolio balance (enforced on Safe balance + deposit amount):**
|
|
427
428
|
|
|
428
|
-
- Ethereum Mainnet (1) / USDC or
|
|
429
|
-
- Base (8453) and Arbitrum (42161) / USDC or EURC: 10 units
|
|
429
|
+
- Ethereum Mainnet (1) / USDC, EURC, USDT, or PYUSD: 10,000 units
|
|
430
|
+
- Base (8453) and Arbitrum (42161) / USDC or EURC: 10 units (EURC is not on Arbitrum)
|
|
430
431
|
- WETH: about **$10,000** of ETH on Ethereum Mainnet, **$10** on Base and Arbitrum
|
|
431
432
|
- NVDAc: about **$10** on Base
|
|
432
433
|
|
|
@@ -465,13 +466,13 @@ if (credited.status === "credited") {
|
|
|
465
466
|
**Note:**
|
|
466
467
|
|
|
467
468
|
- Amount must be in least decimal units. For USDC (6 decimals): 1 USDC = 1000000
|
|
468
|
-
- `asset` is required (`"USDC"`, `"WETH"`, `"EURC"`, or `"NVDAc"` — EURC on Mainnet/Base
|
|
469
|
+
- `asset` is required (`"USDC"`, `"WETH"`, `"EURC"`, `"USDT"`, `"PYUSD"`, or `"NVDAc"` — EURC on Mainnet/Base, USDT and PYUSD on Mainnet, NVDAc on Base); token address is selected from that for the chain. Depositing an asset on a chain where it does not exist throws before any transfer.
|
|
469
470
|
- The total Safe balance must meet the per-asset minimum after the deposit (see above). WETH uses a live ETH/USD price, so the wei threshold moves with the market.
|
|
470
471
|
- Call `connectAccount()` on the **same** `ZyfaiSDK` instance before `sendDeposit()`. The method uses that session's JWT when it calls `log_deposit` after the transfer.
|
|
471
472
|
- `sendDeposit()` confirms the ERC-20 transaction and registers its lifecycle, then returns its ID. Call `waitForDepositCredit()` only when the UI needs to wait for custody credit; otherwise track it later with `getDepositStatus()`.
|
|
472
473
|
- `depositFunds()` remains a compatibility wrapper that calls both steps and waits through the normal completion window; it **rejects** if credit is not confirmed in that window (track in-flight deposits with `getDepositStatus()` or call `waitForDepositCredit()` with a longer `timeoutMs`).
|
|
473
474
|
- If first-deposit protocol patching fails, the transfer still runs. `sendDeposit()` throws if deposit registration is not accepted; retry `logDeposit()` after `connectAccount()`.
|
|
474
|
-
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, EURC, and NVDAc**, each across the chains it exists on (EURC on Mainnet/Base, NVDAc on Base → `assetTypeSettings.[usdc|eth|eurc|nvdac]`). Pass optional `strategy` (`"conservative"` default, `"aggressive"` or `"yieldmaxxing"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
|
|
475
|
+
- **First deposit only** (before transfer + `log_deposit`): if the USDC profile has no `chains` yet, the SDK patches protocols for **USDC, WETH, EURC, USDT, PYUSD, and NVDAc**, each across the chains it exists on (EURC on Mainnet/Base, USDT and PYUSD on Mainnet, NVDAc on Base → `assetTypeSettings.[usdc|eth|eurc|usdt|pyusd|nvdac]`). Pass optional `strategy` (`"conservative"` default, `"aggressive"` or `"yieldmaxxing"`) — same role as the former `deploySafe` strategy argument. Later deposits skip this.
|
|
475
476
|
- **`strategy` is ignored on later deposits, and no error is raised.** Re-running the patch would overwrite a protocol selection the user may have customised, so passing `"yieldmaxxing"` to an account that has already deposited leaves it on its current strategy. To change an existing account, use `setStrategyWithProtocols` or `setAssetStrategy` (not `updateUserProfile` alone):
|
|
476
477
|
|
|
477
478
|
```typescript
|
|
@@ -843,7 +844,7 @@ console.log("Active protocols:", userDetails.user.protocols.length); // Should b
|
|
|
843
844
|
|
|
844
845
|
**Note**:
|
|
845
846
|
- User must be authenticated (automatically done via `connectAccount()`)
|
|
846
|
-
- Clears protocols for USDC, WETH, EURC, and NVDAc
|
|
847
|
+
- Clears protocols for USDC, WETH, EURC, USDT, PYUSD, and NVDAc
|
|
847
848
|
- To resume operations, call `resumeAgent()` or `updateUserProfile()` with the desired protocols
|
|
848
849
|
|
|
849
850
|
#### Splitting Management
|
|
@@ -1298,11 +1299,18 @@ main();
|
|
|
1298
1299
|
|
|
1299
1300
|
### Example 2: Browser Integration with React
|
|
1300
1301
|
|
|
1302
|
+
Demo only. Constructing the SDK in the page ships the API key in the bundle, so it is public. A native app binary can be unpacked the same way. In production, keep the key on your backend and proxy calls to Zyfai. The user still signs SIWE on the device.
|
|
1303
|
+
|
|
1304
|
+
The key alone cannot move funds: deposits and withdrawals need that user's SIWE session and their signature. It can call the data APIs on your quota, list the wallets onboarded under the key (and their TVL), and register extra wallets onto the key.
|
|
1305
|
+
|
|
1306
|
+
CORS applies only when a **browser** calls Zyfai directly. Send us the page origin to whitelist. An iOS or Android app, and a server-side proxy, do not send a browser `Origin` and do not need one.
|
|
1307
|
+
|
|
1301
1308
|
```typescript
|
|
1302
1309
|
import { ZyfaiSDK } from "@zyfai/sdk";
|
|
1303
1310
|
import { useState } from "react";
|
|
1304
1311
|
|
|
1305
1312
|
function SafeDeployment() {
|
|
1313
|
+
// Demo only — this value ends up in the client bundle.
|
|
1306
1314
|
const [sdk] = useState(() => new ZyfaiSDK(process.env.ZYFAI_API_KEY!));
|
|
1307
1315
|
|
|
1308
1316
|
const [userAddress, setUserAddress] = useState<string>("");
|
|
@@ -1401,8 +1409,8 @@ try {
|
|
|
1401
1409
|
|
|
1402
1410
|
## Best Practices
|
|
1403
1411
|
|
|
1404
|
-
1. **Store API Keys Securely**: Never commit API keys to version control
|
|
1405
|
-
2. **Use Environment Variables**: Store keys in `.env` files
|
|
1412
|
+
1. **Store API Keys Securely**: Never commit API keys to version control. Do not ship the key in a frontend bundle or a mobile binary; proxy from your backend. See the note on the React example above.
|
|
1413
|
+
2. **Use Environment Variables**: Store keys in `.env` files on the server, not in a `NEXT_PUBLIC_` / client env var
|
|
1406
1414
|
3. **Check Deployment Status**: Always check if Safe is already deployed before deploying
|
|
1407
1415
|
4. **Handle Errors Gracefully**: Implement proper error handling for all SDK methods
|
|
1408
1416
|
5. **Validate Chain IDs**: Ensure you're using supported chains (Ethereum Mainnet, Base, Arbitrum)
|
|
@@ -1461,7 +1469,7 @@ If `withdrawFunds` returns without a `txHash`, the withdrawal is being processed
|
|
|
1461
1469
|
|
|
1462
1470
|
### Data API CORS Errors
|
|
1463
1471
|
|
|
1464
|
-
|
|
1472
|
+
CORS is enforced by the browser. A native app or a server-side proxy does not need an origin on the whitelist, and the proxy's own URL is not one. If a web page calls `api.zyf.ai` or `defiapi.zyf.ai` directly and you see CORS errors (for example on `onchain-earnings`, `calculate-onchain-earnings`, or `opportunities`), contact Zyfai support with the **page** origin, such as `https://app.example.com`.
|
|
1465
1473
|
|
|
1466
1474
|
## Integration testing
|
|
1467
1475
|
|
package/dist/index.d.mts
CHANGED
|
@@ -627,7 +627,8 @@ interface DepositResponse {
|
|
|
627
627
|
* @remarks
|
|
628
628
|
* `credited` with `balanceCredited: true` means funds are investable.
|
|
629
629
|
*/
|
|
630
|
-
type DepositLifecycleStatus = "handover_pending" | "credited" | "recovered_to_eoa";
|
|
630
|
+
type DepositLifecycleStatus = "handover_pending" | "credited" | "recovered_to_eoa" | "position_pending" | "positioned";
|
|
631
|
+
type DepositPositionOutcome = "pending" | "positioned" | "skipped" | "failed";
|
|
631
632
|
/** Deposit registration and credit lifecycle (execution API). */
|
|
632
633
|
interface DepositLifecycleResponse {
|
|
633
634
|
/** Lifecycle id — pass to {@link ZyfaiSDK.getDepositStatus} / {@link ZyfaiSDK.waitForDepositCredit}. */
|
|
@@ -637,6 +638,32 @@ interface DepositLifecycleResponse {
|
|
|
637
638
|
balanceCredited: boolean;
|
|
638
639
|
/** Backend URL for status polling (informational). */
|
|
639
640
|
statusUrl: string;
|
|
641
|
+
positionOutcome?: DepositPositionOutcome | null;
|
|
642
|
+
crosschain?: boolean;
|
|
643
|
+
executionTxHash?: string | null;
|
|
644
|
+
}
|
|
645
|
+
type WithdrawLifecycleStatus = "accepted" | "redeeming" | "transferring" | "async_requesting" | "async_cooldown" | "async_claiming" | "completed" | "failed";
|
|
646
|
+
interface WithdrawAsyncLeg {
|
|
647
|
+
id: string;
|
|
648
|
+
protocol: string;
|
|
649
|
+
pool: string;
|
|
650
|
+
status: string;
|
|
651
|
+
estimatedClaimAt?: string | null;
|
|
652
|
+
requestTxHash?: string | null;
|
|
653
|
+
claimTxHash?: string | null;
|
|
654
|
+
}
|
|
655
|
+
interface WithdrawLifecycleResponse {
|
|
656
|
+
id: string;
|
|
657
|
+
status: WithdrawLifecycleStatus;
|
|
658
|
+
chainId: number;
|
|
659
|
+
tokenSymbol?: string | null;
|
|
660
|
+
syncSettled: boolean;
|
|
661
|
+
syncTxHash?: string | null;
|
|
662
|
+
asyncLegs: WithdrawAsyncLeg[];
|
|
663
|
+
failedAsyncIds: string[];
|
|
664
|
+
lastError?: string | null;
|
|
665
|
+
statusUrl: string;
|
|
666
|
+
estimatedClaimAt?: string | null;
|
|
640
667
|
}
|
|
641
668
|
interface LogDepositResponse {
|
|
642
669
|
success: boolean;
|
|
@@ -650,6 +677,22 @@ interface WaitForDepositCreditOptions {
|
|
|
650
677
|
/** Maximum wait before throwing `DepositCreditTimeoutError`. */
|
|
651
678
|
timeoutMs?: number;
|
|
652
679
|
}
|
|
680
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForDepositPosition}. */
|
|
681
|
+
interface WaitForDepositPositionOptions {
|
|
682
|
+
intervalMs?: number;
|
|
683
|
+
timeoutMs?: number;
|
|
684
|
+
}
|
|
685
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForWithdrawSettlement}. */
|
|
686
|
+
interface WaitForWithdrawSettlementOptions {
|
|
687
|
+
intervalMs?: number;
|
|
688
|
+
timeoutMs?: number;
|
|
689
|
+
}
|
|
690
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForWithdrawComplete}. */
|
|
691
|
+
interface WaitForWithdrawCompleteOptions {
|
|
692
|
+
intervalMs?: number;
|
|
693
|
+
timeoutMs?: number;
|
|
694
|
+
cooldownIntervalMs?: number;
|
|
695
|
+
}
|
|
653
696
|
/** Polling overrides for {@link ZyfaiSDK.waitForAgentDepositIntent}. */
|
|
654
697
|
interface WaitForAgentDepositIntentOptions {
|
|
655
698
|
intervalMs?: number;
|
|
@@ -670,6 +713,8 @@ interface WithdrawResponse {
|
|
|
670
713
|
type: "full" | "partial";
|
|
671
714
|
/** Withdrawn amount in least units (decimal string). */
|
|
672
715
|
amount: string;
|
|
716
|
+
/** Lifecycle id for {@link ZyfaiSDK.getWithdrawStatus} / withdraw poll helpers. */
|
|
717
|
+
lifecycle?: WithdrawLifecycleResponse;
|
|
673
718
|
}
|
|
674
719
|
interface AddWalletToSdkResponse {
|
|
675
720
|
success: boolean;
|
|
@@ -1749,6 +1794,21 @@ declare class ZyfaiSDK {
|
|
|
1749
1794
|
* @throws If deposit recovers to EOA or polling fails
|
|
1750
1795
|
*/
|
|
1751
1796
|
waitForDepositCredit(depositId: string, chainId: SupportedChainId, options?: WaitForDepositCreditOptions): Promise<DepositLifecycleResponse>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Poll deposit status until funds are allocated to a protocol position, skipped, or failed.
|
|
1799
|
+
* Crosschain deposits resolve once the bridge tx is recorded (`crosschain: true`, `executionTxHash` set);
|
|
1800
|
+
* the destination-chain allocation is not tracked on this lifecycle.
|
|
1801
|
+
*/
|
|
1802
|
+
waitForDepositPosition(depositId: string, chainId: SupportedChainId, options?: WaitForDepositPositionOptions): Promise<DepositLifecycleResponse>;
|
|
1803
|
+
getWithdrawStatus(withdrawalId: string): Promise<WithdrawLifecycleResponse>;
|
|
1804
|
+
/**
|
|
1805
|
+
* Short poll: completes when sync slice settles, async enters cooldown, or claim is already in flight (resume/retry).
|
|
1806
|
+
*/
|
|
1807
|
+
waitForWithdrawSettlement(withdrawalId: string, chainId: SupportedChainId, options?: WaitForWithdrawSettlementOptions): Promise<WithdrawLifecycleResponse>;
|
|
1808
|
+
/**
|
|
1809
|
+
* Long poll through async cooldown and claim until lifecycle is completed.
|
|
1810
|
+
*/
|
|
1811
|
+
waitForWithdrawComplete(withdrawalId: string, chainId: SupportedChainId, options?: WaitForWithdrawCompleteOptions): Promise<WithdrawLifecycleResponse>;
|
|
1752
1812
|
/**
|
|
1753
1813
|
* Withdraw funds from Safe smart wallet
|
|
1754
1814
|
* Initiates a withdrawal request to the Zyfai API
|
|
@@ -2791,4 +2851,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2791
2851
|
*/
|
|
2792
2852
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2793
2853
|
|
|
2794
|
-
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
|
2854
|
+
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
package/dist/index.d.ts
CHANGED
|
@@ -627,7 +627,8 @@ interface DepositResponse {
|
|
|
627
627
|
* @remarks
|
|
628
628
|
* `credited` with `balanceCredited: true` means funds are investable.
|
|
629
629
|
*/
|
|
630
|
-
type DepositLifecycleStatus = "handover_pending" | "credited" | "recovered_to_eoa";
|
|
630
|
+
type DepositLifecycleStatus = "handover_pending" | "credited" | "recovered_to_eoa" | "position_pending" | "positioned";
|
|
631
|
+
type DepositPositionOutcome = "pending" | "positioned" | "skipped" | "failed";
|
|
631
632
|
/** Deposit registration and credit lifecycle (execution API). */
|
|
632
633
|
interface DepositLifecycleResponse {
|
|
633
634
|
/** Lifecycle id — pass to {@link ZyfaiSDK.getDepositStatus} / {@link ZyfaiSDK.waitForDepositCredit}. */
|
|
@@ -637,6 +638,32 @@ interface DepositLifecycleResponse {
|
|
|
637
638
|
balanceCredited: boolean;
|
|
638
639
|
/** Backend URL for status polling (informational). */
|
|
639
640
|
statusUrl: string;
|
|
641
|
+
positionOutcome?: DepositPositionOutcome | null;
|
|
642
|
+
crosschain?: boolean;
|
|
643
|
+
executionTxHash?: string | null;
|
|
644
|
+
}
|
|
645
|
+
type WithdrawLifecycleStatus = "accepted" | "redeeming" | "transferring" | "async_requesting" | "async_cooldown" | "async_claiming" | "completed" | "failed";
|
|
646
|
+
interface WithdrawAsyncLeg {
|
|
647
|
+
id: string;
|
|
648
|
+
protocol: string;
|
|
649
|
+
pool: string;
|
|
650
|
+
status: string;
|
|
651
|
+
estimatedClaimAt?: string | null;
|
|
652
|
+
requestTxHash?: string | null;
|
|
653
|
+
claimTxHash?: string | null;
|
|
654
|
+
}
|
|
655
|
+
interface WithdrawLifecycleResponse {
|
|
656
|
+
id: string;
|
|
657
|
+
status: WithdrawLifecycleStatus;
|
|
658
|
+
chainId: number;
|
|
659
|
+
tokenSymbol?: string | null;
|
|
660
|
+
syncSettled: boolean;
|
|
661
|
+
syncTxHash?: string | null;
|
|
662
|
+
asyncLegs: WithdrawAsyncLeg[];
|
|
663
|
+
failedAsyncIds: string[];
|
|
664
|
+
lastError?: string | null;
|
|
665
|
+
statusUrl: string;
|
|
666
|
+
estimatedClaimAt?: string | null;
|
|
640
667
|
}
|
|
641
668
|
interface LogDepositResponse {
|
|
642
669
|
success: boolean;
|
|
@@ -650,6 +677,22 @@ interface WaitForDepositCreditOptions {
|
|
|
650
677
|
/** Maximum wait before throwing `DepositCreditTimeoutError`. */
|
|
651
678
|
timeoutMs?: number;
|
|
652
679
|
}
|
|
680
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForDepositPosition}. */
|
|
681
|
+
interface WaitForDepositPositionOptions {
|
|
682
|
+
intervalMs?: number;
|
|
683
|
+
timeoutMs?: number;
|
|
684
|
+
}
|
|
685
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForWithdrawSettlement}. */
|
|
686
|
+
interface WaitForWithdrawSettlementOptions {
|
|
687
|
+
intervalMs?: number;
|
|
688
|
+
timeoutMs?: number;
|
|
689
|
+
}
|
|
690
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForWithdrawComplete}. */
|
|
691
|
+
interface WaitForWithdrawCompleteOptions {
|
|
692
|
+
intervalMs?: number;
|
|
693
|
+
timeoutMs?: number;
|
|
694
|
+
cooldownIntervalMs?: number;
|
|
695
|
+
}
|
|
653
696
|
/** Polling overrides for {@link ZyfaiSDK.waitForAgentDepositIntent}. */
|
|
654
697
|
interface WaitForAgentDepositIntentOptions {
|
|
655
698
|
intervalMs?: number;
|
|
@@ -670,6 +713,8 @@ interface WithdrawResponse {
|
|
|
670
713
|
type: "full" | "partial";
|
|
671
714
|
/** Withdrawn amount in least units (decimal string). */
|
|
672
715
|
amount: string;
|
|
716
|
+
/** Lifecycle id for {@link ZyfaiSDK.getWithdrawStatus} / withdraw poll helpers. */
|
|
717
|
+
lifecycle?: WithdrawLifecycleResponse;
|
|
673
718
|
}
|
|
674
719
|
interface AddWalletToSdkResponse {
|
|
675
720
|
success: boolean;
|
|
@@ -1749,6 +1794,21 @@ declare class ZyfaiSDK {
|
|
|
1749
1794
|
* @throws If deposit recovers to EOA or polling fails
|
|
1750
1795
|
*/
|
|
1751
1796
|
waitForDepositCredit(depositId: string, chainId: SupportedChainId, options?: WaitForDepositCreditOptions): Promise<DepositLifecycleResponse>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Poll deposit status until funds are allocated to a protocol position, skipped, or failed.
|
|
1799
|
+
* Crosschain deposits resolve once the bridge tx is recorded (`crosschain: true`, `executionTxHash` set);
|
|
1800
|
+
* the destination-chain allocation is not tracked on this lifecycle.
|
|
1801
|
+
*/
|
|
1802
|
+
waitForDepositPosition(depositId: string, chainId: SupportedChainId, options?: WaitForDepositPositionOptions): Promise<DepositLifecycleResponse>;
|
|
1803
|
+
getWithdrawStatus(withdrawalId: string): Promise<WithdrawLifecycleResponse>;
|
|
1804
|
+
/**
|
|
1805
|
+
* Short poll: completes when sync slice settles, async enters cooldown, or claim is already in flight (resume/retry).
|
|
1806
|
+
*/
|
|
1807
|
+
waitForWithdrawSettlement(withdrawalId: string, chainId: SupportedChainId, options?: WaitForWithdrawSettlementOptions): Promise<WithdrawLifecycleResponse>;
|
|
1808
|
+
/**
|
|
1809
|
+
* Long poll through async cooldown and claim until lifecycle is completed.
|
|
1810
|
+
*/
|
|
1811
|
+
waitForWithdrawComplete(withdrawalId: string, chainId: SupportedChainId, options?: WaitForWithdrawCompleteOptions): Promise<WithdrawLifecycleResponse>;
|
|
1752
1812
|
/**
|
|
1753
1813
|
* Withdraw funds from Safe smart wallet
|
|
1754
1814
|
* Initiates a withdrawal request to the Zyfai API
|
|
@@ -2791,4 +2851,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2791
2851
|
*/
|
|
2792
2852
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2793
2853
|
|
|
2794
|
-
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WalletTVL, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
|
2854
|
+
export { ALLOWED_HISTORY_DAYS, API_ENDPOINT, type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type AllocationDetail, type AllowedHistoryDays, type ApyPosition, type AsyncWithdrawal, type AsyncWithdrawalStatus, type BackendEnvironment, type BankrProvider, type BankrProviderConfig, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstTopupResponse, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryEntry, type HistoryFeeData, type HistoryPosition, type HistoryRebalanceLog, type HistoryResponse, INTENT_EXECUTOR, INTENT_SMART_SESSIONS, LOCAL_DATA_API_BASE_URL, LOCAL_EXECUTION_API_BASE_URL, LOCAL_WS_URL, type LiquidityDropEvent, type LogDepositResponse, type NewCollateralDetectedEvent, OWNABLE_VALIDATOR, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, POOL_MODULE_ADDRESSES, PROXY_EXECUTOR, type PolicyData, type Pool, type Portfolio, type PortfolioAssetBalance, type PortfolioByAssetType, type PortfolioByChain, type PortfolioDetailed, type PortfolioDetailedResponse, type PortfolioResponse, type PortfolioToken, type PositionSlot, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, SAFE_7579_ADDRESS, type SDKConfig, SMART_SESSIONS_FALLBACK, SMART_SESSIONS_VALIDATOR, STAGING_DATA_API_BASE_URL, STAGING_EXECUTION_API_BASE_URL, STAGING_WS_URL, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VolumeResponse, WS_ENDPOINT, WS_URLS, type WaitForDepositCreditOptions, type WaitForDepositPositionOptions, type WaitForWithdrawCompleteOptions, type WaitForWithdrawSettlementOptions, type WalletTVL, type WithdrawAsyncLeg, type WithdrawLifecycleResponse, type WithdrawLifecycleStatus, type WithdrawResponse, type ZyfaiEventFilters, type ZyfaiEventHandlers, ZyfaiSDK, createBankrProvider, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
package/dist/index.js
CHANGED
|
@@ -120,10 +120,11 @@ var ENDPOINTS = {
|
|
|
120
120
|
USER_AGENT_DEPOSIT_INTENT_CONSUME: (actionId) => `/users/me/agent-deposit-intents/${encodeURIComponent(actionId)}/consume`,
|
|
121
121
|
USER_AGENT_DEPOSIT_INTENT_COMPLETE: (actionId) => `/users/me/agent-deposit-intents/${encodeURIComponent(actionId)}/complete`,
|
|
122
122
|
AGENT_DEPOSIT_INTENT_RESOLVE: "/agent-deposit-intents/resolve",
|
|
123
|
-
USER_WITHDRAW: "/users/withdraw",
|
|
124
|
-
PARTIAL_WITHDRAW: "/users/partial-withdraw",
|
|
123
|
+
USER_WITHDRAW: "/users/withdraw/v2",
|
|
124
|
+
PARTIAL_WITHDRAW: "/users/partial-withdraw/v2",
|
|
125
125
|
LOG_DEPOSIT: "/users/log_deposit/v2",
|
|
126
|
-
DEPOSIT_STATUS: (depositId) => `/users/deposits/${depositId}`,
|
|
126
|
+
DEPOSIT_STATUS: (depositId) => `/users/deposits/${depositId}/v2`,
|
|
127
|
+
WITHDRAW_STATUS: (withdrawalId) => `/users/withdrawals/${withdrawalId}`,
|
|
127
128
|
// Safe Deployment (single endpoint)
|
|
128
129
|
SAFE_DEPLOY: "/users/safe-deploy",
|
|
129
130
|
// Multichain deploy for predeployed (pool) wallets — deploys + rotates the
|
|
@@ -450,6 +451,11 @@ function sleep(ms) {
|
|
|
450
451
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
451
452
|
}
|
|
452
453
|
|
|
454
|
+
// src/utils/withdraw-lifecycle-polling.ts
|
|
455
|
+
function isWithdrawSettlementTerminal(status) {
|
|
456
|
+
return status === "completed" || status === "async_cooldown" || status === "async_claiming";
|
|
457
|
+
}
|
|
458
|
+
|
|
453
459
|
// src/utils/token-price.ts
|
|
454
460
|
var PRICE_SCALE = 8;
|
|
455
461
|
var parseTokenUsdPrice = (response) => {
|
|
@@ -712,6 +718,33 @@ var DEPOSIT_CREDIT_TIMEOUT_MS = {
|
|
|
712
718
|
};
|
|
713
719
|
var getDepositCreditIntervalMs = (chainId) => DEPOSIT_CREDIT_INTERVAL_MS[chainId];
|
|
714
720
|
var getDepositCreditTimeoutMs = (chainId) => DEPOSIT_CREDIT_TIMEOUT_MS[chainId];
|
|
721
|
+
var USER_OP_LIFECYCLE_INTERVAL_MS = {
|
|
722
|
+
1: 4e3,
|
|
723
|
+
8453: 1e3,
|
|
724
|
+
42161: 1e3
|
|
725
|
+
};
|
|
726
|
+
var USER_OP_LIFECYCLE_TIMEOUT_MS = {
|
|
727
|
+
1: 18e4,
|
|
728
|
+
8453: 9e4,
|
|
729
|
+
42161: 9e4
|
|
730
|
+
};
|
|
731
|
+
var ASYNC_WITHDRAW_COOLDOWN_POLL_INTERVAL_MS = 6e4;
|
|
732
|
+
var ASYNC_WITHDRAW_CLAIM_GRACE_MS = 6 * 60 * 60 * 1e3;
|
|
733
|
+
var getUserOpLifecycleIntervalMs = (chainId) => USER_OP_LIFECYCLE_INTERVAL_MS[chainId];
|
|
734
|
+
var getUserOpLifecycleTimeoutMs = (chainId) => USER_OP_LIFECYCLE_TIMEOUT_MS[chainId];
|
|
735
|
+
function nextWithdrawCompleteDeadline(startedAt, previousDeadline, estimatedClaimAt, options) {
|
|
736
|
+
if (options.explicitTimeoutMs != null) {
|
|
737
|
+
return startedAt + options.explicitTimeoutMs;
|
|
738
|
+
}
|
|
739
|
+
let deadline = previousDeadline ?? startedAt + options.fallbackMs;
|
|
740
|
+
if (estimatedClaimAt) {
|
|
741
|
+
const claimAt = Date.parse(estimatedClaimAt);
|
|
742
|
+
if (!Number.isNaN(claimAt)) {
|
|
743
|
+
deadline = Math.max(deadline, claimAt + options.graceMs);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return deadline;
|
|
747
|
+
}
|
|
715
748
|
var AGENT_DEPOSIT_INTENT_INTERVAL_MS = 1500;
|
|
716
749
|
var AGENT_DEPOSIT_INTENT_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
717
750
|
var formatMinPortfolioLabel = (raw, decimals, symbol) => {
|
|
@@ -1752,6 +1785,28 @@ var DepositCreditTimeoutError = class extends Error {
|
|
|
1752
1785
|
this.name = "DepositCreditTimeoutError";
|
|
1753
1786
|
}
|
|
1754
1787
|
};
|
|
1788
|
+
var DepositPositionTimeoutError = class extends Error {
|
|
1789
|
+
constructor(depositId) {
|
|
1790
|
+
super(`Timed out waiting for deposit ${depositId} to reach a position`);
|
|
1791
|
+
this.name = "DepositPositionTimeoutError";
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
var WithdrawSettlementTimeoutError = class extends Error {
|
|
1795
|
+
constructor(withdrawalId) {
|
|
1796
|
+
super(
|
|
1797
|
+
`Timed out waiting for withdraw lifecycle ${withdrawalId} to settle`
|
|
1798
|
+
);
|
|
1799
|
+
this.name = "WithdrawSettlementTimeoutError";
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
var WithdrawCompleteTimeoutError = class extends Error {
|
|
1803
|
+
constructor(withdrawalId) {
|
|
1804
|
+
super(
|
|
1805
|
+
`Timed out waiting for withdraw lifecycle ${withdrawalId} to complete`
|
|
1806
|
+
);
|
|
1807
|
+
this.name = "WithdrawCompleteTimeoutError";
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1755
1810
|
var AgentDepositIntentTimeoutError = class extends Error {
|
|
1756
1811
|
constructor(actionId) {
|
|
1757
1812
|
super(`Timed out waiting for agent deposit intent ${actionId} to complete`);
|
|
@@ -3772,7 +3827,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3772
3827
|
const started = Date.now();
|
|
3773
3828
|
while (Date.now() - started < timeoutMs) {
|
|
3774
3829
|
const status = await this.getDepositStatus(depositId);
|
|
3775
|
-
if (status.status
|
|
3830
|
+
if (status.balanceCredited && status.status !== "recovered_to_eoa") {
|
|
3776
3831
|
return status;
|
|
3777
3832
|
}
|
|
3778
3833
|
if (status.status === "recovered_to_eoa") {
|
|
@@ -3787,6 +3842,134 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3787
3842
|
}
|
|
3788
3843
|
throw new DepositCreditTimeoutError(depositId);
|
|
3789
3844
|
}
|
|
3845
|
+
/**
|
|
3846
|
+
* Poll deposit status until funds are allocated to a protocol position, skipped, or failed.
|
|
3847
|
+
* Crosschain deposits resolve once the bridge tx is recorded (`crosschain: true`, `executionTxHash` set);
|
|
3848
|
+
* the destination-chain allocation is not tracked on this lifecycle.
|
|
3849
|
+
*/
|
|
3850
|
+
async waitForDepositPosition(depositId, chainId, options) {
|
|
3851
|
+
if (!depositId) {
|
|
3852
|
+
throw new Error("Deposit ID is required");
|
|
3853
|
+
}
|
|
3854
|
+
if (!isSupportedChain(chainId)) {
|
|
3855
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
3856
|
+
}
|
|
3857
|
+
const intervalMs = options?.intervalMs ?? getUserOpLifecycleIntervalMs(chainId);
|
|
3858
|
+
const timeoutMs = options?.timeoutMs ?? getUserOpLifecycleTimeoutMs(chainId);
|
|
3859
|
+
const started = Date.now();
|
|
3860
|
+
while (Date.now() - started < timeoutMs) {
|
|
3861
|
+
const status = await this.getDepositStatus(depositId);
|
|
3862
|
+
if (status.positionOutcome === "failed") {
|
|
3863
|
+
throw new Error(
|
|
3864
|
+
`Deposit ${depositId} position allocation failed (status=${status.status})`
|
|
3865
|
+
);
|
|
3866
|
+
}
|
|
3867
|
+
if (status.status === "positioned") {
|
|
3868
|
+
return status;
|
|
3869
|
+
}
|
|
3870
|
+
if (status.positionOutcome === "skipped") {
|
|
3871
|
+
return status;
|
|
3872
|
+
}
|
|
3873
|
+
if (status.crosschain && status.executionTxHash) {
|
|
3874
|
+
return status;
|
|
3875
|
+
}
|
|
3876
|
+
if (status.status === "recovered_to_eoa") {
|
|
3877
|
+
throw new Error(
|
|
3878
|
+
`Deposit ${depositId} recovered to EOA; position was not opened`
|
|
3879
|
+
);
|
|
3880
|
+
}
|
|
3881
|
+
await sleep(intervalMs);
|
|
3882
|
+
}
|
|
3883
|
+
throw new DepositPositionTimeoutError(depositId);
|
|
3884
|
+
}
|
|
3885
|
+
async getWithdrawStatus(withdrawalId) {
|
|
3886
|
+
if (!withdrawalId) {
|
|
3887
|
+
throw new Error("Withdrawal lifecycle ID is required");
|
|
3888
|
+
}
|
|
3889
|
+
await this.authenticateUser();
|
|
3890
|
+
return this.httpClient.get(
|
|
3891
|
+
ENDPOINTS.WITHDRAW_STATUS(withdrawalId)
|
|
3892
|
+
);
|
|
3893
|
+
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Short poll: completes when sync slice settles, async enters cooldown, or claim is already in flight (resume/retry).
|
|
3896
|
+
*/
|
|
3897
|
+
async waitForWithdrawSettlement(withdrawalId, chainId, options) {
|
|
3898
|
+
if (!withdrawalId) {
|
|
3899
|
+
throw new Error("Withdrawal lifecycle ID is required");
|
|
3900
|
+
}
|
|
3901
|
+
if (!isSupportedChain(chainId)) {
|
|
3902
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
3903
|
+
}
|
|
3904
|
+
const intervalMs = options?.intervalMs ?? getUserOpLifecycleIntervalMs(chainId);
|
|
3905
|
+
const timeoutMs = options?.timeoutMs ?? getUserOpLifecycleTimeoutMs(chainId);
|
|
3906
|
+
const started = Date.now();
|
|
3907
|
+
while (Date.now() - started < timeoutMs) {
|
|
3908
|
+
const status = await this.getWithdrawStatus(withdrawalId);
|
|
3909
|
+
if (isWithdrawSettlementTerminal(status.status)) {
|
|
3910
|
+
return status;
|
|
3911
|
+
}
|
|
3912
|
+
if (status.status === "failed") {
|
|
3913
|
+
throw new Error(
|
|
3914
|
+
`Withdraw ${withdrawalId} failed: ${status.lastError ?? "unknown"}`
|
|
3915
|
+
);
|
|
3916
|
+
}
|
|
3917
|
+
await sleep(intervalMs);
|
|
3918
|
+
}
|
|
3919
|
+
throw new WithdrawSettlementTimeoutError(withdrawalId);
|
|
3920
|
+
}
|
|
3921
|
+
/**
|
|
3922
|
+
* Long poll through async cooldown and claim until lifecycle is completed.
|
|
3923
|
+
*/
|
|
3924
|
+
async waitForWithdrawComplete(withdrawalId, chainId, options) {
|
|
3925
|
+
if (!withdrawalId) {
|
|
3926
|
+
throw new Error("Withdrawal lifecycle ID is required");
|
|
3927
|
+
}
|
|
3928
|
+
if (!isSupportedChain(chainId)) {
|
|
3929
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
3930
|
+
}
|
|
3931
|
+
const fastIntervalMs = options?.intervalMs ?? getUserOpLifecycleIntervalMs(chainId);
|
|
3932
|
+
const cooldownIntervalMs = options?.cooldownIntervalMs ?? ASYNC_WITHDRAW_COOLDOWN_POLL_INTERVAL_MS;
|
|
3933
|
+
const started = Date.now();
|
|
3934
|
+
const fallbackMs = getUserOpLifecycleTimeoutMs(chainId) + ASYNC_WITHDRAW_CLAIM_GRACE_MS;
|
|
3935
|
+
let deadlineMs = nextWithdrawCompleteDeadline(
|
|
3936
|
+
started,
|
|
3937
|
+
void 0,
|
|
3938
|
+
void 0,
|
|
3939
|
+
{
|
|
3940
|
+
explicitTimeoutMs: options?.timeoutMs,
|
|
3941
|
+
graceMs: ASYNC_WITHDRAW_CLAIM_GRACE_MS,
|
|
3942
|
+
fallbackMs
|
|
3943
|
+
}
|
|
3944
|
+
);
|
|
3945
|
+
while (true) {
|
|
3946
|
+
const status = await this.getWithdrawStatus(withdrawalId);
|
|
3947
|
+
if (status.status === "completed") {
|
|
3948
|
+
return status;
|
|
3949
|
+
}
|
|
3950
|
+
if (status.status === "failed") {
|
|
3951
|
+
throw new Error(
|
|
3952
|
+
`Withdraw ${withdrawalId} failed: ${status.lastError ?? "unknown"}`
|
|
3953
|
+
);
|
|
3954
|
+
}
|
|
3955
|
+
deadlineMs = nextWithdrawCompleteDeadline(
|
|
3956
|
+
started,
|
|
3957
|
+
deadlineMs,
|
|
3958
|
+
status.estimatedClaimAt,
|
|
3959
|
+
{
|
|
3960
|
+
explicitTimeoutMs: options?.timeoutMs,
|
|
3961
|
+
graceMs: ASYNC_WITHDRAW_CLAIM_GRACE_MS,
|
|
3962
|
+
fallbackMs
|
|
3963
|
+
}
|
|
3964
|
+
);
|
|
3965
|
+
if (Date.now() >= deadlineMs) {
|
|
3966
|
+
break;
|
|
3967
|
+
}
|
|
3968
|
+
const intervalMs = status.status === "async_cooldown" ? cooldownIntervalMs : fastIntervalMs;
|
|
3969
|
+
await sleep(intervalMs);
|
|
3970
|
+
}
|
|
3971
|
+
throw new WithdrawCompleteTimeoutError(withdrawalId);
|
|
3972
|
+
}
|
|
3790
3973
|
/**
|
|
3791
3974
|
* Withdraw funds from Safe smart wallet
|
|
3792
3975
|
* Initiates a withdrawal request to the Zyfai API
|
|
@@ -3882,17 +4065,28 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3882
4065
|
response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
|
|
3883
4066
|
params: { chainId, tokenSymbol }
|
|
3884
4067
|
});
|
|
3885
|
-
console.log(JSON.stringify(response, null, 2));
|
|
3886
4068
|
}
|
|
3887
4069
|
const success = response?.success ?? true;
|
|
3888
4070
|
const message = response?.message || "Withdrawal request sent";
|
|
3889
4071
|
const txHash = response?.txHash || response?.transactionHash;
|
|
4072
|
+
const lifecycleId = response?.id;
|
|
4073
|
+
const lifecycle = lifecycleId && response?.statusUrl ? {
|
|
4074
|
+
id: lifecycleId,
|
|
4075
|
+
status: "accepted",
|
|
4076
|
+
chainId,
|
|
4077
|
+
tokenSymbol: tokenSymbol ?? null,
|
|
4078
|
+
syncSettled: false,
|
|
4079
|
+
asyncLegs: [],
|
|
4080
|
+
failedAsyncIds: [],
|
|
4081
|
+
statusUrl: response.statusUrl
|
|
4082
|
+
} : void 0;
|
|
3890
4083
|
return {
|
|
3891
4084
|
success,
|
|
3892
4085
|
message,
|
|
3893
4086
|
txHash,
|
|
3894
4087
|
type: amount ? "partial" : "full",
|
|
3895
|
-
amount: amount || "all"
|
|
4088
|
+
amount: amount || "all",
|
|
4089
|
+
lifecycle
|
|
3896
4090
|
};
|
|
3897
4091
|
} catch (error) {
|
|
3898
4092
|
throw new Error(`Withdrawal failed: ${error.message}`);
|
package/dist/index.mjs
CHANGED
|
@@ -51,10 +51,11 @@ var ENDPOINTS = {
|
|
|
51
51
|
USER_AGENT_DEPOSIT_INTENT_CONSUME: (actionId) => `/users/me/agent-deposit-intents/${encodeURIComponent(actionId)}/consume`,
|
|
52
52
|
USER_AGENT_DEPOSIT_INTENT_COMPLETE: (actionId) => `/users/me/agent-deposit-intents/${encodeURIComponent(actionId)}/complete`,
|
|
53
53
|
AGENT_DEPOSIT_INTENT_RESOLVE: "/agent-deposit-intents/resolve",
|
|
54
|
-
USER_WITHDRAW: "/users/withdraw",
|
|
55
|
-
PARTIAL_WITHDRAW: "/users/partial-withdraw",
|
|
54
|
+
USER_WITHDRAW: "/users/withdraw/v2",
|
|
55
|
+
PARTIAL_WITHDRAW: "/users/partial-withdraw/v2",
|
|
56
56
|
LOG_DEPOSIT: "/users/log_deposit/v2",
|
|
57
|
-
DEPOSIT_STATUS: (depositId) => `/users/deposits/${depositId}`,
|
|
57
|
+
DEPOSIT_STATUS: (depositId) => `/users/deposits/${depositId}/v2`,
|
|
58
|
+
WITHDRAW_STATUS: (withdrawalId) => `/users/withdrawals/${withdrawalId}`,
|
|
58
59
|
// Safe Deployment (single endpoint)
|
|
59
60
|
SAFE_DEPLOY: "/users/safe-deploy",
|
|
60
61
|
// Multichain deploy for predeployed (pool) wallets — deploys + rotates the
|
|
@@ -381,6 +382,11 @@ function sleep(ms) {
|
|
|
381
382
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
382
383
|
}
|
|
383
384
|
|
|
385
|
+
// src/utils/withdraw-lifecycle-polling.ts
|
|
386
|
+
function isWithdrawSettlementTerminal(status) {
|
|
387
|
+
return status === "completed" || status === "async_cooldown" || status === "async_claiming";
|
|
388
|
+
}
|
|
389
|
+
|
|
384
390
|
// src/utils/token-price.ts
|
|
385
391
|
var PRICE_SCALE = 8;
|
|
386
392
|
var parseTokenUsdPrice = (response) => {
|
|
@@ -643,6 +649,33 @@ var DEPOSIT_CREDIT_TIMEOUT_MS = {
|
|
|
643
649
|
};
|
|
644
650
|
var getDepositCreditIntervalMs = (chainId) => DEPOSIT_CREDIT_INTERVAL_MS[chainId];
|
|
645
651
|
var getDepositCreditTimeoutMs = (chainId) => DEPOSIT_CREDIT_TIMEOUT_MS[chainId];
|
|
652
|
+
var USER_OP_LIFECYCLE_INTERVAL_MS = {
|
|
653
|
+
1: 4e3,
|
|
654
|
+
8453: 1e3,
|
|
655
|
+
42161: 1e3
|
|
656
|
+
};
|
|
657
|
+
var USER_OP_LIFECYCLE_TIMEOUT_MS = {
|
|
658
|
+
1: 18e4,
|
|
659
|
+
8453: 9e4,
|
|
660
|
+
42161: 9e4
|
|
661
|
+
};
|
|
662
|
+
var ASYNC_WITHDRAW_COOLDOWN_POLL_INTERVAL_MS = 6e4;
|
|
663
|
+
var ASYNC_WITHDRAW_CLAIM_GRACE_MS = 6 * 60 * 60 * 1e3;
|
|
664
|
+
var getUserOpLifecycleIntervalMs = (chainId) => USER_OP_LIFECYCLE_INTERVAL_MS[chainId];
|
|
665
|
+
var getUserOpLifecycleTimeoutMs = (chainId) => USER_OP_LIFECYCLE_TIMEOUT_MS[chainId];
|
|
666
|
+
function nextWithdrawCompleteDeadline(startedAt, previousDeadline, estimatedClaimAt, options) {
|
|
667
|
+
if (options.explicitTimeoutMs != null) {
|
|
668
|
+
return startedAt + options.explicitTimeoutMs;
|
|
669
|
+
}
|
|
670
|
+
let deadline = previousDeadline ?? startedAt + options.fallbackMs;
|
|
671
|
+
if (estimatedClaimAt) {
|
|
672
|
+
const claimAt = Date.parse(estimatedClaimAt);
|
|
673
|
+
if (!Number.isNaN(claimAt)) {
|
|
674
|
+
deadline = Math.max(deadline, claimAt + options.graceMs);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return deadline;
|
|
678
|
+
}
|
|
646
679
|
var AGENT_DEPOSIT_INTENT_INTERVAL_MS = 1500;
|
|
647
680
|
var AGENT_DEPOSIT_INTENT_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
648
681
|
var formatMinPortfolioLabel = (raw, decimals, symbol) => {
|
|
@@ -1703,6 +1736,28 @@ var DepositCreditTimeoutError = class extends Error {
|
|
|
1703
1736
|
this.name = "DepositCreditTimeoutError";
|
|
1704
1737
|
}
|
|
1705
1738
|
};
|
|
1739
|
+
var DepositPositionTimeoutError = class extends Error {
|
|
1740
|
+
constructor(depositId) {
|
|
1741
|
+
super(`Timed out waiting for deposit ${depositId} to reach a position`);
|
|
1742
|
+
this.name = "DepositPositionTimeoutError";
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
var WithdrawSettlementTimeoutError = class extends Error {
|
|
1746
|
+
constructor(withdrawalId) {
|
|
1747
|
+
super(
|
|
1748
|
+
`Timed out waiting for withdraw lifecycle ${withdrawalId} to settle`
|
|
1749
|
+
);
|
|
1750
|
+
this.name = "WithdrawSettlementTimeoutError";
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
var WithdrawCompleteTimeoutError = class extends Error {
|
|
1754
|
+
constructor(withdrawalId) {
|
|
1755
|
+
super(
|
|
1756
|
+
`Timed out waiting for withdraw lifecycle ${withdrawalId} to complete`
|
|
1757
|
+
);
|
|
1758
|
+
this.name = "WithdrawCompleteTimeoutError";
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1706
1761
|
var AgentDepositIntentTimeoutError = class extends Error {
|
|
1707
1762
|
constructor(actionId) {
|
|
1708
1763
|
super(`Timed out waiting for agent deposit intent ${actionId} to complete`);
|
|
@@ -3723,7 +3778,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3723
3778
|
const started = Date.now();
|
|
3724
3779
|
while (Date.now() - started < timeoutMs) {
|
|
3725
3780
|
const status = await this.getDepositStatus(depositId);
|
|
3726
|
-
if (status.status
|
|
3781
|
+
if (status.balanceCredited && status.status !== "recovered_to_eoa") {
|
|
3727
3782
|
return status;
|
|
3728
3783
|
}
|
|
3729
3784
|
if (status.status === "recovered_to_eoa") {
|
|
@@ -3738,6 +3793,134 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3738
3793
|
}
|
|
3739
3794
|
throw new DepositCreditTimeoutError(depositId);
|
|
3740
3795
|
}
|
|
3796
|
+
/**
|
|
3797
|
+
* Poll deposit status until funds are allocated to a protocol position, skipped, or failed.
|
|
3798
|
+
* Crosschain deposits resolve once the bridge tx is recorded (`crosschain: true`, `executionTxHash` set);
|
|
3799
|
+
* the destination-chain allocation is not tracked on this lifecycle.
|
|
3800
|
+
*/
|
|
3801
|
+
async waitForDepositPosition(depositId, chainId, options) {
|
|
3802
|
+
if (!depositId) {
|
|
3803
|
+
throw new Error("Deposit ID is required");
|
|
3804
|
+
}
|
|
3805
|
+
if (!isSupportedChain(chainId)) {
|
|
3806
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
3807
|
+
}
|
|
3808
|
+
const intervalMs = options?.intervalMs ?? getUserOpLifecycleIntervalMs(chainId);
|
|
3809
|
+
const timeoutMs = options?.timeoutMs ?? getUserOpLifecycleTimeoutMs(chainId);
|
|
3810
|
+
const started = Date.now();
|
|
3811
|
+
while (Date.now() - started < timeoutMs) {
|
|
3812
|
+
const status = await this.getDepositStatus(depositId);
|
|
3813
|
+
if (status.positionOutcome === "failed") {
|
|
3814
|
+
throw new Error(
|
|
3815
|
+
`Deposit ${depositId} position allocation failed (status=${status.status})`
|
|
3816
|
+
);
|
|
3817
|
+
}
|
|
3818
|
+
if (status.status === "positioned") {
|
|
3819
|
+
return status;
|
|
3820
|
+
}
|
|
3821
|
+
if (status.positionOutcome === "skipped") {
|
|
3822
|
+
return status;
|
|
3823
|
+
}
|
|
3824
|
+
if (status.crosschain && status.executionTxHash) {
|
|
3825
|
+
return status;
|
|
3826
|
+
}
|
|
3827
|
+
if (status.status === "recovered_to_eoa") {
|
|
3828
|
+
throw new Error(
|
|
3829
|
+
`Deposit ${depositId} recovered to EOA; position was not opened`
|
|
3830
|
+
);
|
|
3831
|
+
}
|
|
3832
|
+
await sleep(intervalMs);
|
|
3833
|
+
}
|
|
3834
|
+
throw new DepositPositionTimeoutError(depositId);
|
|
3835
|
+
}
|
|
3836
|
+
async getWithdrawStatus(withdrawalId) {
|
|
3837
|
+
if (!withdrawalId) {
|
|
3838
|
+
throw new Error("Withdrawal lifecycle ID is required");
|
|
3839
|
+
}
|
|
3840
|
+
await this.authenticateUser();
|
|
3841
|
+
return this.httpClient.get(
|
|
3842
|
+
ENDPOINTS.WITHDRAW_STATUS(withdrawalId)
|
|
3843
|
+
);
|
|
3844
|
+
}
|
|
3845
|
+
/**
|
|
3846
|
+
* Short poll: completes when sync slice settles, async enters cooldown, or claim is already in flight (resume/retry).
|
|
3847
|
+
*/
|
|
3848
|
+
async waitForWithdrawSettlement(withdrawalId, chainId, options) {
|
|
3849
|
+
if (!withdrawalId) {
|
|
3850
|
+
throw new Error("Withdrawal lifecycle ID is required");
|
|
3851
|
+
}
|
|
3852
|
+
if (!isSupportedChain(chainId)) {
|
|
3853
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
3854
|
+
}
|
|
3855
|
+
const intervalMs = options?.intervalMs ?? getUserOpLifecycleIntervalMs(chainId);
|
|
3856
|
+
const timeoutMs = options?.timeoutMs ?? getUserOpLifecycleTimeoutMs(chainId);
|
|
3857
|
+
const started = Date.now();
|
|
3858
|
+
while (Date.now() - started < timeoutMs) {
|
|
3859
|
+
const status = await this.getWithdrawStatus(withdrawalId);
|
|
3860
|
+
if (isWithdrawSettlementTerminal(status.status)) {
|
|
3861
|
+
return status;
|
|
3862
|
+
}
|
|
3863
|
+
if (status.status === "failed") {
|
|
3864
|
+
throw new Error(
|
|
3865
|
+
`Withdraw ${withdrawalId} failed: ${status.lastError ?? "unknown"}`
|
|
3866
|
+
);
|
|
3867
|
+
}
|
|
3868
|
+
await sleep(intervalMs);
|
|
3869
|
+
}
|
|
3870
|
+
throw new WithdrawSettlementTimeoutError(withdrawalId);
|
|
3871
|
+
}
|
|
3872
|
+
/**
|
|
3873
|
+
* Long poll through async cooldown and claim until lifecycle is completed.
|
|
3874
|
+
*/
|
|
3875
|
+
async waitForWithdrawComplete(withdrawalId, chainId, options) {
|
|
3876
|
+
if (!withdrawalId) {
|
|
3877
|
+
throw new Error("Withdrawal lifecycle ID is required");
|
|
3878
|
+
}
|
|
3879
|
+
if (!isSupportedChain(chainId)) {
|
|
3880
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
3881
|
+
}
|
|
3882
|
+
const fastIntervalMs = options?.intervalMs ?? getUserOpLifecycleIntervalMs(chainId);
|
|
3883
|
+
const cooldownIntervalMs = options?.cooldownIntervalMs ?? ASYNC_WITHDRAW_COOLDOWN_POLL_INTERVAL_MS;
|
|
3884
|
+
const started = Date.now();
|
|
3885
|
+
const fallbackMs = getUserOpLifecycleTimeoutMs(chainId) + ASYNC_WITHDRAW_CLAIM_GRACE_MS;
|
|
3886
|
+
let deadlineMs = nextWithdrawCompleteDeadline(
|
|
3887
|
+
started,
|
|
3888
|
+
void 0,
|
|
3889
|
+
void 0,
|
|
3890
|
+
{
|
|
3891
|
+
explicitTimeoutMs: options?.timeoutMs,
|
|
3892
|
+
graceMs: ASYNC_WITHDRAW_CLAIM_GRACE_MS,
|
|
3893
|
+
fallbackMs
|
|
3894
|
+
}
|
|
3895
|
+
);
|
|
3896
|
+
while (true) {
|
|
3897
|
+
const status = await this.getWithdrawStatus(withdrawalId);
|
|
3898
|
+
if (status.status === "completed") {
|
|
3899
|
+
return status;
|
|
3900
|
+
}
|
|
3901
|
+
if (status.status === "failed") {
|
|
3902
|
+
throw new Error(
|
|
3903
|
+
`Withdraw ${withdrawalId} failed: ${status.lastError ?? "unknown"}`
|
|
3904
|
+
);
|
|
3905
|
+
}
|
|
3906
|
+
deadlineMs = nextWithdrawCompleteDeadline(
|
|
3907
|
+
started,
|
|
3908
|
+
deadlineMs,
|
|
3909
|
+
status.estimatedClaimAt,
|
|
3910
|
+
{
|
|
3911
|
+
explicitTimeoutMs: options?.timeoutMs,
|
|
3912
|
+
graceMs: ASYNC_WITHDRAW_CLAIM_GRACE_MS,
|
|
3913
|
+
fallbackMs
|
|
3914
|
+
}
|
|
3915
|
+
);
|
|
3916
|
+
if (Date.now() >= deadlineMs) {
|
|
3917
|
+
break;
|
|
3918
|
+
}
|
|
3919
|
+
const intervalMs = status.status === "async_cooldown" ? cooldownIntervalMs : fastIntervalMs;
|
|
3920
|
+
await sleep(intervalMs);
|
|
3921
|
+
}
|
|
3922
|
+
throw new WithdrawCompleteTimeoutError(withdrawalId);
|
|
3923
|
+
}
|
|
3741
3924
|
/**
|
|
3742
3925
|
* Withdraw funds from Safe smart wallet
|
|
3743
3926
|
* Initiates a withdrawal request to the Zyfai API
|
|
@@ -3833,17 +4016,28 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3833
4016
|
response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
|
|
3834
4017
|
params: { chainId, tokenSymbol }
|
|
3835
4018
|
});
|
|
3836
|
-
console.log(JSON.stringify(response, null, 2));
|
|
3837
4019
|
}
|
|
3838
4020
|
const success = response?.success ?? true;
|
|
3839
4021
|
const message = response?.message || "Withdrawal request sent";
|
|
3840
4022
|
const txHash = response?.txHash || response?.transactionHash;
|
|
4023
|
+
const lifecycleId = response?.id;
|
|
4024
|
+
const lifecycle = lifecycleId && response?.statusUrl ? {
|
|
4025
|
+
id: lifecycleId,
|
|
4026
|
+
status: "accepted",
|
|
4027
|
+
chainId,
|
|
4028
|
+
tokenSymbol: tokenSymbol ?? null,
|
|
4029
|
+
syncSettled: false,
|
|
4030
|
+
asyncLegs: [],
|
|
4031
|
+
failedAsyncIds: [],
|
|
4032
|
+
statusUrl: response.statusUrl
|
|
4033
|
+
} : void 0;
|
|
3841
4034
|
return {
|
|
3842
4035
|
success,
|
|
3843
4036
|
message,
|
|
3844
4037
|
txHash,
|
|
3845
4038
|
type: amount ? "partial" : "full",
|
|
3846
|
-
amount: amount || "all"
|
|
4039
|
+
amount: amount || "all",
|
|
4040
|
+
lifecycle
|
|
3847
4041
|
};
|
|
3848
4042
|
} catch (error) {
|
|
3849
4043
|
throw new Error(`Withdrawal failed: ${error.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "TypeScript SDK for self-custodial Zyfai yield agents: discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum, Base, and Arbitrum",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|