@zyfai/sdk 0.4.0 → 0.5.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 +11 -11
- package/dist/index.d.mts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +68 -10
- package/dist/index.mjs +68 -10
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@zyfai/sdk)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
TypeScript SDK for
|
|
6
|
+
TypeScript SDK for integrating self-custodial Zyfai yield agents. Discover DeFi opportunities and manage deposits, withdrawals, positions, and strategies across Ethereum Mainnet, Base, and Arbitrum.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Get an API key from [sma.zyf.ai](https://sma.zyf.ai/). For chat-based integrations, use the hosted MCP endpoint at [`https://mcp.zyf.ai/mcp`](https://mcp.zyf.ai/mcp) (registry ID: `io.github.ondefy/zyfai`).
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
- **
|
|
12
|
+
- **First-Deposit Onboarding**: The first deposit assigns a pre-deployed Safe and active session to the user's EOA
|
|
13
13
|
- **Flexible Authentication**: Support for private keys and modern wallet providers
|
|
14
14
|
- **Multi-Chain Support**: Works on Ethereum Mainnet, Base, and Arbitrum
|
|
15
15
|
- **Yield Optimization**: Access to multiple DeFi protocols and strategies
|
|
@@ -51,7 +51,7 @@ After changesets merge to `main`, a maintainer runs `npm run version-packages`,
|
|
|
51
51
|
|
|
52
52
|
1. **API Key**: Single API key for both Execution API (Safe deployment, transactions, session keys) and Data API (earnings, opportunities, analytics)
|
|
53
53
|
|
|
54
|
-
**Get your API key from [Zyfai Dashboard](https://
|
|
54
|
+
**Get your API key from [Zyfai Dashboard](https://sma.zyf.ai)**
|
|
55
55
|
|
|
56
56
|
## Quick Start
|
|
57
57
|
|
|
@@ -426,9 +426,9 @@ Transfer tokens to your Safe smart wallet. Token address is automatically select
|
|
|
426
426
|
**Minimum portfolio balance (enforced on Safe balance + deposit amount):**
|
|
427
427
|
|
|
428
428
|
- Ethereum Mainnet (1) / USDC or EURC: 10,000 units
|
|
429
|
-
- Base (8453) and Arbitrum (42161) / USDC or EURC:
|
|
430
|
-
- WETH: about **$10,000** of ETH on Ethereum Mainnet, **$
|
|
431
|
-
- NVDAc: about **$
|
|
429
|
+
- Base (8453) and Arbitrum (42161) / USDC or EURC: 10 units
|
|
430
|
+
- WETH: about **$10,000** of ETH on Ethereum Mainnet, **$10** on Base and Arbitrum
|
|
431
|
+
- NVDAc: about **$10** on Base
|
|
432
432
|
|
|
433
433
|
Minimums for WETH and NVDAc are quoted in dollars and converted at deposit time from the live USD price (Data API `GET /api/v2/price?token=eth` and `?token=nvdac`, same API key as the SDK), so the on-chain threshold moves with the market.
|
|
434
434
|
|
|
@@ -1131,9 +1131,9 @@ resolves to zero protocols for NVDAc and the agent has nothing to deploy into.
|
|
|
1131
1131
|
Every NVDAc withdrawal is therefore a delayed one — read
|
|
1132
1132
|
[Total balance](#total-balance) before showing a balance.
|
|
1133
1133
|
|
|
1134
|
-
**The minimum deposit is $
|
|
1134
|
+
**The minimum deposit is $10 of NVDAc, not 10 NVDAc.** It is converted from
|
|
1135
1135
|
the live price at deposit time, so the threshold in token units moves daily
|
|
1136
|
-
(around `0.
|
|
1136
|
+
(around `0.044` NVDAc at $225/share).
|
|
1137
1137
|
|
|
1138
1138
|
**Deposits pause when the market is closed**, typically over the weekend. Funds
|
|
1139
1139
|
stay idle in the Safe and are deployed at the next open; other assets are
|
|
@@ -1145,7 +1145,7 @@ unaffected. `getPortfolio` returns ready-to-display copy in
|
|
|
1145
1145
|
// Chains default to Base, the only one NVDAc exists on.
|
|
1146
1146
|
await sdk.setAssetStrategy({ asset: "NVDAc", strategy: "yieldmaxxing" });
|
|
1147
1147
|
|
|
1148
|
-
// 1 NVDAc = 100000000 (8 decimals). Must leave at least ~$
|
|
1148
|
+
// 1 NVDAc = 100000000 (8 decimals). Must leave at least ~$10 in the Safe.
|
|
1149
1149
|
const sentNvda = await sdk.sendDeposit(userAddress, 8453, "100000000", "NVDAc");
|
|
1150
1150
|
await sdk.waitForDepositCredit(sentNvda.registration.id, 8453);
|
|
1151
1151
|
```
|
|
@@ -1555,7 +1555,7 @@ npx vitest src/integration/get-protocols.integration.test.ts --fileParallelism=f
|
|
|
1555
1555
|
|
|
1556
1556
|
Tests call `describe.skipIf(!integrationEnvReady())` and skip cleanly when `.env.test` is missing or invalid.
|
|
1557
1557
|
|
|
1558
|
-
When the execution API is **local** or **staging** and `NODE_ENV` is not `production`, the SDK skips client-side minimum portfolio checks so small test deposits (e.g. 0.1 USDC) work without topping up
|
|
1558
|
+
When the execution API is **local** or **staging** and `NODE_ENV` is not `production`, the SDK skips client-side minimum portfolio checks so small test deposits (e.g. 0.1 USDC) work without topping up 10 USDC on Base. Production (`api.zyf.ai`) always enforces real minimums.
|
|
1559
1559
|
|
|
1560
1560
|
**Release smoke (`deposit-withdraw`)** on Base USDC: **local and staging only** — **0.1 USDC** round-trip (fund the test EOA on Base with ~0.1 USDC plus gas). Staging api must have **`SMOKE_AMOUNTS_ENABLED=true`** in its `.env` (see `zyfai-api/docs/deployment.md`). One withdraw per run. Production does not run fund-spending integration tests.
|
|
1561
1561
|
|
package/dist/index.d.mts
CHANGED
|
@@ -650,6 +650,17 @@ interface WaitForDepositCreditOptions {
|
|
|
650
650
|
/** Maximum wait before throwing `DepositCreditTimeoutError`. */
|
|
651
651
|
timeoutMs?: number;
|
|
652
652
|
}
|
|
653
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForAgentDepositIntent}. */
|
|
654
|
+
interface WaitForAgentDepositIntentOptions {
|
|
655
|
+
intervalMs?: number;
|
|
656
|
+
timeoutMs?: number;
|
|
657
|
+
}
|
|
658
|
+
/** Options for {@link ZyfaiSDK.waitForAgentDepositHandover}. */
|
|
659
|
+
interface WaitForAgentDepositHandoverOptions extends WaitForAgentDepositIntentOptions {
|
|
660
|
+
/** When true (default), poll through custody credit after intent completes. */
|
|
661
|
+
waitForCredit?: boolean;
|
|
662
|
+
credit?: WaitForDepositCreditOptions;
|
|
663
|
+
}
|
|
653
664
|
/** Result of {@link ZyfaiSDK.withdrawFunds}. */
|
|
654
665
|
interface WithdrawResponse {
|
|
655
666
|
success: boolean;
|
|
@@ -2340,6 +2351,27 @@ declare class ZyfaiSDK {
|
|
|
2340
2351
|
getAgentDepositIntentStatus(actionId: string): Promise<{
|
|
2341
2352
|
data: AgentDepositIntentStatus;
|
|
2342
2353
|
}>;
|
|
2354
|
+
/**
|
|
2355
|
+
* Poll MCP deposit-intent status until the signing page registers the transfer.
|
|
2356
|
+
*
|
|
2357
|
+
* @group Agent management
|
|
2358
|
+
*
|
|
2359
|
+
* @throws `AgentDepositIntentTimeoutError` when the intent stays pending past `timeoutMs`
|
|
2360
|
+
* @throws When the intent expires before completion
|
|
2361
|
+
*/
|
|
2362
|
+
waitForAgentDepositIntent(actionId: string, options?: WaitForAgentDepositIntentOptions): Promise<AgentDepositIntentStatus>;
|
|
2363
|
+
/**
|
|
2364
|
+
* Wait for MCP signing completion, then optionally through custody credit.
|
|
2365
|
+
*
|
|
2366
|
+
* Pair with {@link ZyfaiSDK.prepareDeposit} and a browser `signingUrl` from
|
|
2367
|
+
* `createAgentDepositIntent`. Start this poll as soon as the user has the link.
|
|
2368
|
+
*
|
|
2369
|
+
* @group Agent management
|
|
2370
|
+
*/
|
|
2371
|
+
waitForAgentDepositHandover(actionId: string, chainId: SupportedChainId, options?: WaitForAgentDepositHandoverOptions): Promise<{
|
|
2372
|
+
intent: AgentDepositIntentStatus;
|
|
2373
|
+
credited?: DepositLifecycleResponse;
|
|
2374
|
+
}>;
|
|
2343
2375
|
/**
|
|
2344
2376
|
* Mark intent complete after the user signed on zyf.ai (SIWE session).
|
|
2345
2377
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -650,6 +650,17 @@ interface WaitForDepositCreditOptions {
|
|
|
650
650
|
/** Maximum wait before throwing `DepositCreditTimeoutError`. */
|
|
651
651
|
timeoutMs?: number;
|
|
652
652
|
}
|
|
653
|
+
/** Polling overrides for {@link ZyfaiSDK.waitForAgentDepositIntent}. */
|
|
654
|
+
interface WaitForAgentDepositIntentOptions {
|
|
655
|
+
intervalMs?: number;
|
|
656
|
+
timeoutMs?: number;
|
|
657
|
+
}
|
|
658
|
+
/** Options for {@link ZyfaiSDK.waitForAgentDepositHandover}. */
|
|
659
|
+
interface WaitForAgentDepositHandoverOptions extends WaitForAgentDepositIntentOptions {
|
|
660
|
+
/** When true (default), poll through custody credit after intent completes. */
|
|
661
|
+
waitForCredit?: boolean;
|
|
662
|
+
credit?: WaitForDepositCreditOptions;
|
|
663
|
+
}
|
|
653
664
|
/** Result of {@link ZyfaiSDK.withdrawFunds}. */
|
|
654
665
|
interface WithdrawResponse {
|
|
655
666
|
success: boolean;
|
|
@@ -2340,6 +2351,27 @@ declare class ZyfaiSDK {
|
|
|
2340
2351
|
getAgentDepositIntentStatus(actionId: string): Promise<{
|
|
2341
2352
|
data: AgentDepositIntentStatus;
|
|
2342
2353
|
}>;
|
|
2354
|
+
/**
|
|
2355
|
+
* Poll MCP deposit-intent status until the signing page registers the transfer.
|
|
2356
|
+
*
|
|
2357
|
+
* @group Agent management
|
|
2358
|
+
*
|
|
2359
|
+
* @throws `AgentDepositIntentTimeoutError` when the intent stays pending past `timeoutMs`
|
|
2360
|
+
* @throws When the intent expires before completion
|
|
2361
|
+
*/
|
|
2362
|
+
waitForAgentDepositIntent(actionId: string, options?: WaitForAgentDepositIntentOptions): Promise<AgentDepositIntentStatus>;
|
|
2363
|
+
/**
|
|
2364
|
+
* Wait for MCP signing completion, then optionally through custody credit.
|
|
2365
|
+
*
|
|
2366
|
+
* Pair with {@link ZyfaiSDK.prepareDeposit} and a browser `signingUrl` from
|
|
2367
|
+
* `createAgentDepositIntent`. Start this poll as soon as the user has the link.
|
|
2368
|
+
*
|
|
2369
|
+
* @group Agent management
|
|
2370
|
+
*/
|
|
2371
|
+
waitForAgentDepositHandover(actionId: string, chainId: SupportedChainId, options?: WaitForAgentDepositHandoverOptions): Promise<{
|
|
2372
|
+
intent: AgentDepositIntentStatus;
|
|
2373
|
+
credited?: DepositLifecycleResponse;
|
|
2374
|
+
}>;
|
|
2343
2375
|
/**
|
|
2344
2376
|
* Mark intent complete after the user signed on zyf.ai (SIWE session).
|
|
2345
2377
|
*
|
package/dist/index.js
CHANGED
|
@@ -648,22 +648,22 @@ var MIN_PORTFOLIO_BALANCE = {
|
|
|
648
648
|
// 10,000 EURC (6 decimals)
|
|
649
649
|
},
|
|
650
650
|
8453: {
|
|
651
|
-
USDC:
|
|
652
|
-
//
|
|
653
|
-
EURC:
|
|
654
|
-
//
|
|
651
|
+
USDC: 10n * 10n ** 6n,
|
|
652
|
+
// 10 USDC (6 decimals)
|
|
653
|
+
EURC: 10n * 10n ** 6n
|
|
654
|
+
// 10 EURC (6 decimals)
|
|
655
655
|
},
|
|
656
656
|
42161: {
|
|
657
|
-
USDC:
|
|
658
|
-
//
|
|
659
|
-
EURC:
|
|
660
|
-
//
|
|
657
|
+
USDC: 10n * 10n ** 6n,
|
|
658
|
+
// 10 USDC (6 decimals)
|
|
659
|
+
EURC: 10n * 10n ** 6n
|
|
660
|
+
// 10 EURC (6 decimals)
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
663
|
var MIN_PORTFOLIO_USD = {
|
|
664
664
|
1: { WETH: 10000n },
|
|
665
|
-
8453: { WETH:
|
|
666
|
-
42161: { WETH:
|
|
665
|
+
8453: { WETH: 10n, NVDAc: 10n },
|
|
666
|
+
42161: { WETH: 10n }
|
|
667
667
|
};
|
|
668
668
|
var DEPOSIT_CREDIT_INTERVAL_MS = {
|
|
669
669
|
1: 2e3,
|
|
@@ -680,6 +680,8 @@ var DEPOSIT_CREDIT_TIMEOUT_MS = {
|
|
|
680
680
|
};
|
|
681
681
|
var getDepositCreditIntervalMs = (chainId) => DEPOSIT_CREDIT_INTERVAL_MS[chainId];
|
|
682
682
|
var getDepositCreditTimeoutMs = (chainId) => DEPOSIT_CREDIT_TIMEOUT_MS[chainId];
|
|
683
|
+
var AGENT_DEPOSIT_INTENT_INTERVAL_MS = 1500;
|
|
684
|
+
var AGENT_DEPOSIT_INTENT_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
683
685
|
var formatMinPortfolioLabel = (raw, decimals, symbol) => {
|
|
684
686
|
const base2 = 10n ** BigInt(decimals);
|
|
685
687
|
const whole = raw / base2;
|
|
@@ -1664,6 +1666,12 @@ var DepositCreditTimeoutError = class extends Error {
|
|
|
1664
1666
|
this.name = "DepositCreditTimeoutError";
|
|
1665
1667
|
}
|
|
1666
1668
|
};
|
|
1669
|
+
var AgentDepositIntentTimeoutError = class extends Error {
|
|
1670
|
+
constructor(actionId) {
|
|
1671
|
+
super(`Timed out waiting for agent deposit intent ${actionId} to complete`);
|
|
1672
|
+
this.name = "AgentDepositIntentTimeoutError";
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1667
1675
|
var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
|
|
1668
1676
|
var _ZyfaiSDK = class _ZyfaiSDK {
|
|
1669
1677
|
/**
|
|
@@ -4982,6 +4990,56 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4982
4990
|
ENDPOINTS.USER_AGENT_DEPOSIT_INTENT(actionId)
|
|
4983
4991
|
);
|
|
4984
4992
|
}
|
|
4993
|
+
/**
|
|
4994
|
+
* Poll MCP deposit-intent status until the signing page registers the transfer.
|
|
4995
|
+
*
|
|
4996
|
+
* @group Agent management
|
|
4997
|
+
*
|
|
4998
|
+
* @throws `AgentDepositIntentTimeoutError` when the intent stays pending past `timeoutMs`
|
|
4999
|
+
* @throws When the intent expires before completion
|
|
5000
|
+
*/
|
|
5001
|
+
async waitForAgentDepositIntent(actionId, options) {
|
|
5002
|
+
if (!actionId) {
|
|
5003
|
+
throw new Error("actionId is required");
|
|
5004
|
+
}
|
|
5005
|
+
const intervalMs = options?.intervalMs ?? AGENT_DEPOSIT_INTENT_INTERVAL_MS;
|
|
5006
|
+
const timeoutMs = options?.timeoutMs ?? AGENT_DEPOSIT_INTENT_TIMEOUT_MS;
|
|
5007
|
+
const started = Date.now();
|
|
5008
|
+
while (Date.now() - started < timeoutMs) {
|
|
5009
|
+
const { data } = await this.getAgentDepositIntentStatus(actionId);
|
|
5010
|
+
if (data.status === "completed") {
|
|
5011
|
+
return data;
|
|
5012
|
+
}
|
|
5013
|
+
if (data.status === "expired") {
|
|
5014
|
+
throw new Error(`Agent deposit intent ${actionId} expired`);
|
|
5015
|
+
}
|
|
5016
|
+
if (Date.now() - started >= timeoutMs) {
|
|
5017
|
+
break;
|
|
5018
|
+
}
|
|
5019
|
+
await sleep(intervalMs);
|
|
5020
|
+
}
|
|
5021
|
+
throw new AgentDepositIntentTimeoutError(actionId);
|
|
5022
|
+
}
|
|
5023
|
+
/**
|
|
5024
|
+
* Wait for MCP signing completion, then optionally through custody credit.
|
|
5025
|
+
*
|
|
5026
|
+
* Pair with {@link ZyfaiSDK.prepareDeposit} and a browser `signingUrl` from
|
|
5027
|
+
* `createAgentDepositIntent`. Start this poll as soon as the user has the link.
|
|
5028
|
+
*
|
|
5029
|
+
* @group Agent management
|
|
5030
|
+
*/
|
|
5031
|
+
async waitForAgentDepositHandover(actionId, chainId, options) {
|
|
5032
|
+
const intent = await this.waitForAgentDepositIntent(actionId, options);
|
|
5033
|
+
if (options?.waitForCredit === false || !intent.depositId) {
|
|
5034
|
+
return { intent };
|
|
5035
|
+
}
|
|
5036
|
+
const credited = await this.waitForDepositCredit(
|
|
5037
|
+
intent.depositId,
|
|
5038
|
+
chainId,
|
|
5039
|
+
options?.credit
|
|
5040
|
+
);
|
|
5041
|
+
return { intent, credited };
|
|
5042
|
+
}
|
|
4985
5043
|
/**
|
|
4986
5044
|
* Mark intent complete after the user signed on zyf.ai (SIWE session).
|
|
4987
5045
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -580,22 +580,22 @@ var MIN_PORTFOLIO_BALANCE = {
|
|
|
580
580
|
// 10,000 EURC (6 decimals)
|
|
581
581
|
},
|
|
582
582
|
8453: {
|
|
583
|
-
USDC:
|
|
584
|
-
//
|
|
585
|
-
EURC:
|
|
586
|
-
//
|
|
583
|
+
USDC: 10n * 10n ** 6n,
|
|
584
|
+
// 10 USDC (6 decimals)
|
|
585
|
+
EURC: 10n * 10n ** 6n
|
|
586
|
+
// 10 EURC (6 decimals)
|
|
587
587
|
},
|
|
588
588
|
42161: {
|
|
589
|
-
USDC:
|
|
590
|
-
//
|
|
591
|
-
EURC:
|
|
592
|
-
//
|
|
589
|
+
USDC: 10n * 10n ** 6n,
|
|
590
|
+
// 10 USDC (6 decimals)
|
|
591
|
+
EURC: 10n * 10n ** 6n
|
|
592
|
+
// 10 EURC (6 decimals)
|
|
593
593
|
}
|
|
594
594
|
};
|
|
595
595
|
var MIN_PORTFOLIO_USD = {
|
|
596
596
|
1: { WETH: 10000n },
|
|
597
|
-
8453: { WETH:
|
|
598
|
-
42161: { WETH:
|
|
597
|
+
8453: { WETH: 10n, NVDAc: 10n },
|
|
598
|
+
42161: { WETH: 10n }
|
|
599
599
|
};
|
|
600
600
|
var DEPOSIT_CREDIT_INTERVAL_MS = {
|
|
601
601
|
1: 2e3,
|
|
@@ -612,6 +612,8 @@ var DEPOSIT_CREDIT_TIMEOUT_MS = {
|
|
|
612
612
|
};
|
|
613
613
|
var getDepositCreditIntervalMs = (chainId) => DEPOSIT_CREDIT_INTERVAL_MS[chainId];
|
|
614
614
|
var getDepositCreditTimeoutMs = (chainId) => DEPOSIT_CREDIT_TIMEOUT_MS[chainId];
|
|
615
|
+
var AGENT_DEPOSIT_INTENT_INTERVAL_MS = 1500;
|
|
616
|
+
var AGENT_DEPOSIT_INTENT_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
615
617
|
var formatMinPortfolioLabel = (raw, decimals, symbol) => {
|
|
616
618
|
const base2 = 10n ** BigInt(decimals);
|
|
617
619
|
const whole = raw / base2;
|
|
@@ -1616,6 +1618,12 @@ var DepositCreditTimeoutError = class extends Error {
|
|
|
1616
1618
|
this.name = "DepositCreditTimeoutError";
|
|
1617
1619
|
}
|
|
1618
1620
|
};
|
|
1621
|
+
var AgentDepositIntentTimeoutError = class extends Error {
|
|
1622
|
+
constructor(actionId) {
|
|
1623
|
+
super(`Timed out waiting for agent deposit intent ${actionId} to complete`);
|
|
1624
|
+
this.name = "AgentDepositIntentTimeoutError";
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1619
1627
|
var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
|
|
1620
1628
|
var _ZyfaiSDK = class _ZyfaiSDK {
|
|
1621
1629
|
/**
|
|
@@ -4934,6 +4942,56 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
4934
4942
|
ENDPOINTS.USER_AGENT_DEPOSIT_INTENT(actionId)
|
|
4935
4943
|
);
|
|
4936
4944
|
}
|
|
4945
|
+
/**
|
|
4946
|
+
* Poll MCP deposit-intent status until the signing page registers the transfer.
|
|
4947
|
+
*
|
|
4948
|
+
* @group Agent management
|
|
4949
|
+
*
|
|
4950
|
+
* @throws `AgentDepositIntentTimeoutError` when the intent stays pending past `timeoutMs`
|
|
4951
|
+
* @throws When the intent expires before completion
|
|
4952
|
+
*/
|
|
4953
|
+
async waitForAgentDepositIntent(actionId, options) {
|
|
4954
|
+
if (!actionId) {
|
|
4955
|
+
throw new Error("actionId is required");
|
|
4956
|
+
}
|
|
4957
|
+
const intervalMs = options?.intervalMs ?? AGENT_DEPOSIT_INTENT_INTERVAL_MS;
|
|
4958
|
+
const timeoutMs = options?.timeoutMs ?? AGENT_DEPOSIT_INTENT_TIMEOUT_MS;
|
|
4959
|
+
const started = Date.now();
|
|
4960
|
+
while (Date.now() - started < timeoutMs) {
|
|
4961
|
+
const { data } = await this.getAgentDepositIntentStatus(actionId);
|
|
4962
|
+
if (data.status === "completed") {
|
|
4963
|
+
return data;
|
|
4964
|
+
}
|
|
4965
|
+
if (data.status === "expired") {
|
|
4966
|
+
throw new Error(`Agent deposit intent ${actionId} expired`);
|
|
4967
|
+
}
|
|
4968
|
+
if (Date.now() - started >= timeoutMs) {
|
|
4969
|
+
break;
|
|
4970
|
+
}
|
|
4971
|
+
await sleep(intervalMs);
|
|
4972
|
+
}
|
|
4973
|
+
throw new AgentDepositIntentTimeoutError(actionId);
|
|
4974
|
+
}
|
|
4975
|
+
/**
|
|
4976
|
+
* Wait for MCP signing completion, then optionally through custody credit.
|
|
4977
|
+
*
|
|
4978
|
+
* Pair with {@link ZyfaiSDK.prepareDeposit} and a browser `signingUrl` from
|
|
4979
|
+
* `createAgentDepositIntent`. Start this poll as soon as the user has the link.
|
|
4980
|
+
*
|
|
4981
|
+
* @group Agent management
|
|
4982
|
+
*/
|
|
4983
|
+
async waitForAgentDepositHandover(actionId, chainId, options) {
|
|
4984
|
+
const intent = await this.waitForAgentDepositIntent(actionId, options);
|
|
4985
|
+
if (options?.waitForCredit === false || !intent.depositId) {
|
|
4986
|
+
return { intent };
|
|
4987
|
+
}
|
|
4988
|
+
const credited = await this.waitForDepositCredit(
|
|
4989
|
+
intent.depositId,
|
|
4990
|
+
chainId,
|
|
4991
|
+
options?.credit
|
|
4992
|
+
);
|
|
4993
|
+
return { intent, credited };
|
|
4994
|
+
}
|
|
4937
4995
|
/**
|
|
4938
4996
|
* Mark intent complete after the user signed on zyf.ai (SIWE session).
|
|
4939
4997
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TypeScript SDK for Zyfai
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
"defi",
|
|
45
45
|
"yield",
|
|
46
46
|
"yield-optimization",
|
|
47
|
+
"yield-agent",
|
|
48
|
+
"defi-agent",
|
|
49
|
+
"self-custodial",
|
|
47
50
|
"web3",
|
|
48
51
|
"ethereum",
|
|
49
52
|
"smart-wallet",
|