@zyfai/sdk 0.1.21 → 0.1.22
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 +2 -2
- package/dist/index.d.mts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +6 -11
- package/dist/index.mjs +6 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -370,6 +370,7 @@ if (result.success) {
|
|
|
370
370
|
### 5. Withdraw Funds
|
|
371
371
|
|
|
372
372
|
Initiate a withdrawal from your Safe. **Note: Withdrawals are processed asynchronously by the backend.**
|
|
373
|
+
Funds are always withdrawn to the Safe owner's address (userAddress).
|
|
373
374
|
|
|
374
375
|
```typescript
|
|
375
376
|
// Full withdrawal
|
|
@@ -379,8 +380,7 @@ const result = await sdk.withdrawFunds(userAddress, 8453);
|
|
|
379
380
|
const result = await sdk.withdrawFunds(
|
|
380
381
|
userAddress,
|
|
381
382
|
8453,
|
|
382
|
-
"50000000"
|
|
383
|
-
"0xReceiverAddress" // Optional: receiver address
|
|
383
|
+
"50000000" // Amount: 50 USDC = 50 * 10^6
|
|
384
384
|
);
|
|
385
385
|
|
|
386
386
|
if (result.success) {
|
package/dist/index.d.mts
CHANGED
|
@@ -339,7 +339,6 @@ interface DepositResponse {
|
|
|
339
339
|
txHash: string;
|
|
340
340
|
smartWallet: string;
|
|
341
341
|
amount: string;
|
|
342
|
-
status: "pending" | "confirmed" | "failed";
|
|
343
342
|
}
|
|
344
343
|
interface WithdrawResponse {
|
|
345
344
|
success: boolean;
|
|
@@ -347,8 +346,6 @@ interface WithdrawResponse {
|
|
|
347
346
|
txHash?: string;
|
|
348
347
|
type: "full" | "partial";
|
|
349
348
|
amount: string;
|
|
350
|
-
receiver: string;
|
|
351
|
-
status: "pending" | "confirmed" | "failed";
|
|
352
349
|
}
|
|
353
350
|
interface AddWalletToSdkResponse {
|
|
354
351
|
success: boolean;
|
|
@@ -579,11 +576,11 @@ declare class ZyfaiSDK {
|
|
|
579
576
|
* Withdraw funds from Safe smart wallet
|
|
580
577
|
* Initiates a withdrawal request to the ZyFAI API
|
|
581
578
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
579
|
+
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
582
580
|
*
|
|
583
581
|
* @param userAddress - User's address (owner of the Safe)
|
|
584
582
|
* @param chainId - Target chain ID
|
|
585
583
|
* @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
|
|
586
|
-
* @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
|
|
587
584
|
* @returns Withdraw response with message and optional transaction hash (available once processed)
|
|
588
585
|
*
|
|
589
586
|
* @example
|
|
@@ -596,12 +593,11 @@ declare class ZyfaiSDK {
|
|
|
596
593
|
* const result = await sdk.withdrawFunds(
|
|
597
594
|
* "0xUser...",
|
|
598
595
|
* 8453,
|
|
599
|
-
* "50000000"
|
|
600
|
-
* "0xReceiver..."
|
|
596
|
+
* "50000000" // 50 USDC = 50 * 10^6
|
|
601
597
|
* );
|
|
602
598
|
* ```
|
|
603
599
|
*/
|
|
604
|
-
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string
|
|
600
|
+
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string): Promise<WithdrawResponse>;
|
|
605
601
|
/**
|
|
606
602
|
* Get available DeFi protocols and pools for a specific chain
|
|
607
603
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -339,7 +339,6 @@ interface DepositResponse {
|
|
|
339
339
|
txHash: string;
|
|
340
340
|
smartWallet: string;
|
|
341
341
|
amount: string;
|
|
342
|
-
status: "pending" | "confirmed" | "failed";
|
|
343
342
|
}
|
|
344
343
|
interface WithdrawResponse {
|
|
345
344
|
success: boolean;
|
|
@@ -347,8 +346,6 @@ interface WithdrawResponse {
|
|
|
347
346
|
txHash?: string;
|
|
348
347
|
type: "full" | "partial";
|
|
349
348
|
amount: string;
|
|
350
|
-
receiver: string;
|
|
351
|
-
status: "pending" | "confirmed" | "failed";
|
|
352
349
|
}
|
|
353
350
|
interface AddWalletToSdkResponse {
|
|
354
351
|
success: boolean;
|
|
@@ -579,11 +576,11 @@ declare class ZyfaiSDK {
|
|
|
579
576
|
* Withdraw funds from Safe smart wallet
|
|
580
577
|
* Initiates a withdrawal request to the ZyFAI API
|
|
581
578
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
579
|
+
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
582
580
|
*
|
|
583
581
|
* @param userAddress - User's address (owner of the Safe)
|
|
584
582
|
* @param chainId - Target chain ID
|
|
585
583
|
* @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
|
|
586
|
-
* @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
|
|
587
584
|
* @returns Withdraw response with message and optional transaction hash (available once processed)
|
|
588
585
|
*
|
|
589
586
|
* @example
|
|
@@ -596,12 +593,11 @@ declare class ZyfaiSDK {
|
|
|
596
593
|
* const result = await sdk.withdrawFunds(
|
|
597
594
|
* "0xUser...",
|
|
598
595
|
* 8453,
|
|
599
|
-
* "50000000"
|
|
600
|
-
* "0xReceiver..."
|
|
596
|
+
* "50000000" // 50 USDC = 50 * 10^6
|
|
601
597
|
* );
|
|
602
598
|
* ```
|
|
603
599
|
*/
|
|
604
|
-
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string
|
|
600
|
+
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string): Promise<WithdrawResponse>;
|
|
605
601
|
/**
|
|
606
602
|
* Get available DeFi protocols and pools for a specific chain
|
|
607
603
|
*
|
package/dist/index.js
CHANGED
|
@@ -1559,8 +1559,7 @@ var ZyfaiSDK = class {
|
|
|
1559
1559
|
success: true,
|
|
1560
1560
|
txHash,
|
|
1561
1561
|
smartWallet: safeAddress,
|
|
1562
|
-
amount: amountBigInt.toString()
|
|
1563
|
-
status: "confirmed"
|
|
1562
|
+
amount: amountBigInt.toString()
|
|
1564
1563
|
};
|
|
1565
1564
|
} catch (error) {
|
|
1566
1565
|
throw new Error(`Deposit failed: ${error.message}`);
|
|
@@ -1570,11 +1569,11 @@ var ZyfaiSDK = class {
|
|
|
1570
1569
|
* Withdraw funds from Safe smart wallet
|
|
1571
1570
|
* Initiates a withdrawal request to the ZyFAI API
|
|
1572
1571
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
1572
|
+
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
1573
1573
|
*
|
|
1574
1574
|
* @param userAddress - User's address (owner of the Safe)
|
|
1575
1575
|
* @param chainId - Target chain ID
|
|
1576
1576
|
* @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
|
|
1577
|
-
* @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
|
|
1578
1577
|
* @returns Withdraw response with message and optional transaction hash (available once processed)
|
|
1579
1578
|
*
|
|
1580
1579
|
* @example
|
|
@@ -1587,12 +1586,11 @@ var ZyfaiSDK = class {
|
|
|
1587
1586
|
* const result = await sdk.withdrawFunds(
|
|
1588
1587
|
* "0xUser...",
|
|
1589
1588
|
* 8453,
|
|
1590
|
-
* "50000000"
|
|
1591
|
-
* "0xReceiver..."
|
|
1589
|
+
* "50000000" // 50 USDC = 50 * 10^6
|
|
1592
1590
|
* );
|
|
1593
1591
|
* ```
|
|
1594
1592
|
*/
|
|
1595
|
-
async withdrawFunds(userAddress, chainId, amount
|
|
1593
|
+
async withdrawFunds(userAddress, chainId, amount) {
|
|
1596
1594
|
try {
|
|
1597
1595
|
if (!userAddress) {
|
|
1598
1596
|
throw new Error("User address is required");
|
|
@@ -1640,8 +1638,7 @@ var ZyfaiSDK = class {
|
|
|
1640
1638
|
if (amount) {
|
|
1641
1639
|
response = await this.httpClient.post(ENDPOINTS.PARTIAL_WITHDRAW, {
|
|
1642
1640
|
chainId,
|
|
1643
|
-
amount
|
|
1644
|
-
receiver: receiver || userAddress
|
|
1641
|
+
amount
|
|
1645
1642
|
});
|
|
1646
1643
|
} else {
|
|
1647
1644
|
response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
|
|
@@ -1656,9 +1653,7 @@ var ZyfaiSDK = class {
|
|
|
1656
1653
|
message,
|
|
1657
1654
|
txHash,
|
|
1658
1655
|
type: amount ? "partial" : "full",
|
|
1659
|
-
amount: amount || "all"
|
|
1660
|
-
receiver: receiver || userAddress,
|
|
1661
|
-
status: success ? "pending" : "failed"
|
|
1656
|
+
amount: amount || "all"
|
|
1662
1657
|
};
|
|
1663
1658
|
} catch (error) {
|
|
1664
1659
|
throw new Error(`Withdrawal failed: ${error.message}`);
|
package/dist/index.mjs
CHANGED
|
@@ -1544,8 +1544,7 @@ var ZyfaiSDK = class {
|
|
|
1544
1544
|
success: true,
|
|
1545
1545
|
txHash,
|
|
1546
1546
|
smartWallet: safeAddress,
|
|
1547
|
-
amount: amountBigInt.toString()
|
|
1548
|
-
status: "confirmed"
|
|
1547
|
+
amount: amountBigInt.toString()
|
|
1549
1548
|
};
|
|
1550
1549
|
} catch (error) {
|
|
1551
1550
|
throw new Error(`Deposit failed: ${error.message}`);
|
|
@@ -1555,11 +1554,11 @@ var ZyfaiSDK = class {
|
|
|
1555
1554
|
* Withdraw funds from Safe smart wallet
|
|
1556
1555
|
* Initiates a withdrawal request to the ZyFAI API
|
|
1557
1556
|
* Note: The withdrawal is processed asynchronously, so txHash may not be immediately available
|
|
1557
|
+
* Funds are always withdrawn to the Safe owner's address (userAddress)
|
|
1558
1558
|
*
|
|
1559
1559
|
* @param userAddress - User's address (owner of the Safe)
|
|
1560
1560
|
* @param chainId - Target chain ID
|
|
1561
1561
|
* @param amount - Optional: Amount in least decimal units to withdraw (partial withdrawal). If not specified, withdraws all funds
|
|
1562
|
-
* @param receiver - Optional: Receiver address. If not specified, sends to Safe owner
|
|
1563
1562
|
* @returns Withdraw response with message and optional transaction hash (available once processed)
|
|
1564
1563
|
*
|
|
1565
1564
|
* @example
|
|
@@ -1572,12 +1571,11 @@ var ZyfaiSDK = class {
|
|
|
1572
1571
|
* const result = await sdk.withdrawFunds(
|
|
1573
1572
|
* "0xUser...",
|
|
1574
1573
|
* 8453,
|
|
1575
|
-
* "50000000"
|
|
1576
|
-
* "0xReceiver..."
|
|
1574
|
+
* "50000000" // 50 USDC = 50 * 10^6
|
|
1577
1575
|
* );
|
|
1578
1576
|
* ```
|
|
1579
1577
|
*/
|
|
1580
|
-
async withdrawFunds(userAddress, chainId, amount
|
|
1578
|
+
async withdrawFunds(userAddress, chainId, amount) {
|
|
1581
1579
|
try {
|
|
1582
1580
|
if (!userAddress) {
|
|
1583
1581
|
throw new Error("User address is required");
|
|
@@ -1625,8 +1623,7 @@ var ZyfaiSDK = class {
|
|
|
1625
1623
|
if (amount) {
|
|
1626
1624
|
response = await this.httpClient.post(ENDPOINTS.PARTIAL_WITHDRAW, {
|
|
1627
1625
|
chainId,
|
|
1628
|
-
amount
|
|
1629
|
-
receiver: receiver || userAddress
|
|
1626
|
+
amount
|
|
1630
1627
|
});
|
|
1631
1628
|
} else {
|
|
1632
1629
|
response = await this.httpClient.get(ENDPOINTS.USER_WITHDRAW, {
|
|
@@ -1641,9 +1638,7 @@ var ZyfaiSDK = class {
|
|
|
1641
1638
|
message,
|
|
1642
1639
|
txHash,
|
|
1643
1640
|
type: amount ? "partial" : "full",
|
|
1644
|
-
amount: amount || "all"
|
|
1645
|
-
receiver: receiver || userAddress,
|
|
1646
|
-
status: success ? "pending" : "failed"
|
|
1641
|
+
amount: amount || "all"
|
|
1647
1642
|
};
|
|
1648
1643
|
} catch (error) {
|
|
1649
1644
|
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.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "TypeScript SDK for ZyFAI Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|