@zyfai/sdk 1.5.0 → 1.8.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 +40 -4
- package/dist/index.d.mts +171 -15
- package/dist/index.d.ts +171 -15
- package/dist/index.js +960 -97
- package/dist/index.mjs +932 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -285,6 +285,40 @@ const provider = await connector.getProvider();
|
|
|
285
285
|
await sdk.connectAccount(provider); // Uses provider's current chain
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
+
**Nested Safe owners (multisig treasury):** connect the parent Safe, then pass the **parent Safe
|
|
289
|
+
address** (not an owner EOA) as `userAddress` on `sendDeposit`. Use a `chainId` where that Safe
|
|
290
|
+
is deployed (for example Ethereum `1` when the treasury only exists on mainnet). The SDK deploys
|
|
291
|
+
a child Zyfai Safe owned by the parent, enables the agent session with EIP-712
|
|
292
|
+
`MultiChainSession` signing, and proposes an ERC-20 `transfer` from the parent. The SDK polls
|
|
293
|
+
Safe Transaction Service and registers the on-chain hash when execution completes.
|
|
294
|
+
|
|
295
|
+
A threshold above 1 connects through WalletConnect or the Safe App, which collects the other
|
|
296
|
+
signatures. A threshold-1 Safe can connect from a script:
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { createSafeOwnerProvider, ZyfaiSDK } from "@zyfai/sdk";
|
|
300
|
+
import { createWalletClient, custom } from "viem";
|
|
301
|
+
import { base } from "viem/chains";
|
|
302
|
+
|
|
303
|
+
// `owner` is the wallet the user already connected. A private key is not required.
|
|
304
|
+
const owner = createWalletClient({
|
|
305
|
+
chain: base,
|
|
306
|
+
transport: custom(window.ethereum),
|
|
307
|
+
});
|
|
308
|
+
const provider = await createSafeOwnerProvider({
|
|
309
|
+
safeAddress: "0xParentSafe",
|
|
310
|
+
owner,
|
|
311
|
+
chain: base,
|
|
312
|
+
});
|
|
313
|
+
const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY! });
|
|
314
|
+
const parent = await sdk.connectAccount(provider, 8453);
|
|
315
|
+
await sdk.sendDeposit(parent, 8453, "100000", "USDC");
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
A 2-of-4 Safe does not use `createSafeOwnerProvider`. Connect that Safe with WalletConnect or
|
|
319
|
+
the Safe App, pass the Safe address to `sendDeposit`, and the other owners confirm in the Safe
|
|
320
|
+
UI. `sendDeposit` waits for that execution.
|
|
321
|
+
|
|
288
322
|
##### `disconnectAccount(): Promise<void>`
|
|
289
323
|
|
|
290
324
|
Disconnect account and clear all authentication state.
|
|
@@ -327,7 +361,7 @@ Get the Smart Wallet (Safe) address for a user.
|
|
|
327
361
|
|
|
328
362
|
##### `deploySafe(userAddress: string, chainId: SupportedChainId, strategy?: Strategy): Promise<DeploySafeResponse>`
|
|
329
363
|
|
|
330
|
-
>
|
|
364
|
+
> Not needed for a predeployed (pool) wallet: `sendDeposit()` deploys the Safe and enables the agent session on first deposit, and this method warns when called for one. Required for an owner that is not predeployed — a contract owner such as a nested Safe, or a legacy self-deployed wallet — where `sendDeposit()` calls it internally.
|
|
331
365
|
|
|
332
366
|
Deploy a Safe smart wallet for a user. **Deployment is handled by the backend API**, which manages all RPC calls and bundler interactions. This avoids rate limiting issues.
|
|
333
367
|
|
|
@@ -458,9 +492,9 @@ it yourself. A matching hash proves what you sign, not that it is safe.
|
|
|
458
492
|
|
|
459
493
|
Session keys enable delegated transaction execution without exposing the main private key.
|
|
460
494
|
|
|
461
|
-
#### Simple Usage
|
|
495
|
+
#### Simple Usage
|
|
462
496
|
|
|
463
|
-
>
|
|
497
|
+
> Not needed for a predeployed (pool) wallet: its agent session is already enabled on-chain, `sendDeposit()` records it after the first deposit, and this method warns when called for one. Required for an owner that is not predeployed — a contract owner such as a nested Safe, or a legacy self-deployed wallet — where `sendDeposit()` calls it internally.
|
|
464
498
|
|
|
465
499
|
The SDK automatically fetches optimal session configuration from Zyfai API:
|
|
466
500
|
|
|
@@ -492,7 +526,7 @@ console.log("User ID:", result.userId);
|
|
|
492
526
|
- The SDK proactively checks if the user already has an active session key and returns early without requiring any signature if one exists
|
|
493
527
|
- The user record must have `smartWallet` and `chainId` set (predeployed assignment / first deposit)
|
|
494
528
|
- Protocol selection is **not** touched by `createSessionKey` — it's set by `deploySafe` and on the first `sendDeposit` call if USDC `chains` are still empty
|
|
495
|
-
-
|
|
529
|
+
- Prefer `sendDeposit()` for partner onboarding; `createSessionKey` stays the explicit entry point for owners that are not predeployed
|
|
496
530
|
- When `alreadyActive` is `true`, `sessionKeyAddress` and `signature` are not available in the response
|
|
497
531
|
|
|
498
532
|
### 4. Send a Deposit
|
|
@@ -1646,6 +1680,7 @@ Vitest loads `.env.test` automatically (`vitest.config.ts`).
|
|
|
1646
1680
|
| `LOCAL_SDK_API_KEYS_ADMIN_API_KEY` | Admin key for `POST /admin/sdk-api-keys` when `ZYFAI_ENV=local` |
|
|
1647
1681
|
| `STAGING_SDK_API_KEYS_ADMIN_API_KEY` | Same when `ZYFAI_ENV=staging` |
|
|
1648
1682
|
| `PRODUCTION_SDK_API_KEYS_ADMIN_API_KEY` | Same when `ZYFAI_ENV=production` |
|
|
1683
|
+
| `NESTED_SAFE_ADDRESS` | Optional parent Safe for `nested-safe-deposit`. Threshold 1 on Base, `PRIVATE_KEY` is an owner, at least 0.1 USDC on the Safe. Omit to skip that suite. |
|
|
1649
1684
|
|
|
1650
1685
|
`ZYFAI_ENV` selects the API stack and which `*_ZYFAI_API_KEY` is passed to `integrationSdkConfig()`.
|
|
1651
1686
|
|
|
@@ -1676,6 +1711,7 @@ Each suite uses `describeIntegrationSuite()` from `utils.ts` with `spendProfile`
|
|
|
1676
1711
|
| Read-only (e.g. `get-protocols`) | local, staging, production | `{ spendProfile: "readonly" }` |
|
|
1677
1712
|
| Fresh funded user (`setupFreshFundedUser`) | local, staging | `{ spendProfile: "spends_funds", credentialGate: "fresh_user" }` — **0.1 USDC** per run |
|
|
1678
1713
|
| Persistent wallet (`PRIVATE_KEY` EOA) | local, staging | `{ spendProfile: "spends_funds" }` (default `credentialGate: "persistent_wallet"`) |
|
|
1714
|
+
| Nested Safe deposit (`NESTED_SAFE_ADDRESS`) | local, staging | `{ spendProfile: "spends_funds", additionalSkipReason: skipNestedSafeAddressReason }` — **0.1 USDC** from the parent Safe, then withdrawn back to that Safe. `sendDeposit` polls Safe Transaction Service for up to 20 minutes. |
|
|
1679
1715
|
|
|
1680
1716
|
Release prep on **staging**: run one file via workspace skill **[backend-smoke](../.cursor/skills/backend-smoke/SKILL.md)** (e.g. `deposit-withdraw` or `send-deposit-wait-credit` for wallet pool / handover). After prod deploy, use **`get-protocols`** (or another `readonly` suite) only.
|
|
1681
1717
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, PublicClient, Address as Address$1, Hex as Hex$1 } from 'viem';
|
|
1
|
+
import { Chain, PublicClient, Address as Address$1, Hex as Hex$1, Account, WalletClient } from 'viem';
|
|
2
2
|
import { hashChainSessions } from '@rhinestone/module-sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1294,11 +1294,15 @@ declare class ZyfaiSDK {
|
|
|
1294
1294
|
signature: Hex;
|
|
1295
1295
|
origin?: string;
|
|
1296
1296
|
}): Promise<LoginResponse>;
|
|
1297
|
+
/** Warn that a deprecated compatibility method was called. */
|
|
1298
|
+
private warnDeprecatedOnboardingMethod;
|
|
1297
1299
|
/**
|
|
1298
|
-
* Warn
|
|
1299
|
-
*
|
|
1300
|
+
* Warn only a pool wallet, which sendDeposit onboards on its own. A contract
|
|
1301
|
+
* owner is never predeployed and reaches these methods through sendDeposit,
|
|
1302
|
+
* so warning unconditionally tells that caller to use what it just called.
|
|
1303
|
+
* Call after authentication, once `isPredeployed` is resolved.
|
|
1300
1304
|
*/
|
|
1301
|
-
private
|
|
1305
|
+
private warnPredeployedOnboardingMethod;
|
|
1302
1306
|
private readonly executionApiUrl;
|
|
1303
1307
|
private readonly bypassMinPortfolio;
|
|
1304
1308
|
/**
|
|
@@ -1542,6 +1546,11 @@ declare class ZyfaiSDK {
|
|
|
1542
1546
|
* from the user record before allowing a transfer to an undeployed pool Safe.
|
|
1543
1547
|
* @private
|
|
1544
1548
|
*/
|
|
1549
|
+
/**
|
|
1550
|
+
* Deploy the child Zyfai Safe and session for a nested (contract) owner.
|
|
1551
|
+
* @private
|
|
1552
|
+
*/
|
|
1553
|
+
private ensureNestedOwnerReadyForDeposit;
|
|
1545
1554
|
private hydrateSessionWallet;
|
|
1546
1555
|
/**
|
|
1547
1556
|
* Resolve the Safe address: backend-assigned for the connected predeployed
|
|
@@ -1569,9 +1578,10 @@ declare class ZyfaiSDK {
|
|
|
1569
1578
|
/**
|
|
1570
1579
|
* Deploy Safe Smart Wallet for a user
|
|
1571
1580
|
*
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1574
|
-
* legacy
|
|
1581
|
+
* Not needed for a predeployed (pool) wallet: {@link ZyfaiSDK.sendDeposit} deploys the Safe and
|
|
1582
|
+
* enables the agent session on first deposit. Required for an owner that is not predeployed —
|
|
1583
|
+
* a contract owner such as a nested Safe, or a legacy self-deployed wallet — where `sendDeposit`
|
|
1584
|
+
* calls this method internally.
|
|
1575
1585
|
*
|
|
1576
1586
|
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1577
1587
|
*
|
|
@@ -1585,11 +1595,11 @@ declare class ZyfaiSDK {
|
|
|
1585
1595
|
*
|
|
1586
1596
|
* @example
|
|
1587
1597
|
* ```typescript
|
|
1588
|
-
* // Preferred: sendDeposit handles
|
|
1598
|
+
* // Preferred: sendDeposit handles onboarding for every owner type
|
|
1589
1599
|
* const sent = await sdk.sendDeposit(userAddress, 8453, amount, "USDC");
|
|
1590
1600
|
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1591
1601
|
*
|
|
1592
|
-
* //
|
|
1602
|
+
* // Explicit: deploy with default conservative strategy
|
|
1593
1603
|
* await sdk.deploySafe(userAddress, 8453);
|
|
1594
1604
|
* ```
|
|
1595
1605
|
*/
|
|
@@ -1598,9 +1608,10 @@ declare class ZyfaiSDK {
|
|
|
1598
1608
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
1599
1609
|
* This is the simplified method that automatically fetches session configuration
|
|
1600
1610
|
*
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1603
|
-
*
|
|
1611
|
+
* Not needed for a predeployed (pool) wallet: its agent session is already enabled on-chain and
|
|
1612
|
+
* {@link ZyfaiSDK.sendDeposit} records it after the first deposit. Required for an owner that is
|
|
1613
|
+
* not predeployed — a contract owner such as a nested Safe, or a legacy self-deployed wallet —
|
|
1614
|
+
* where `sendDeposit` calls this method internally.
|
|
1604
1615
|
*
|
|
1605
1616
|
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1606
1617
|
*
|
|
@@ -1612,11 +1623,11 @@ declare class ZyfaiSDK {
|
|
|
1612
1623
|
*
|
|
1613
1624
|
* @example
|
|
1614
1625
|
* ```typescript
|
|
1615
|
-
* // Preferred: sendDeposit handles session onboarding for
|
|
1626
|
+
* // Preferred: sendDeposit handles session onboarding for every owner type
|
|
1616
1627
|
* const sent = await sdk.sendDeposit(userAddress, 8453, amount, "USDC");
|
|
1617
1628
|
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1618
1629
|
*
|
|
1619
|
-
* //
|
|
1630
|
+
* // Explicit:
|
|
1620
1631
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
1621
1632
|
* ```
|
|
1622
1633
|
*/
|
|
@@ -1625,6 +1636,18 @@ declare class ZyfaiSDK {
|
|
|
1625
1636
|
* Internal method to sign session key
|
|
1626
1637
|
* @private
|
|
1627
1638
|
*/
|
|
1639
|
+
/**
|
|
1640
|
+
* A nested Safe owner signs one MultiChainSession covering every chain in the
|
|
1641
|
+
* session configuration, and the child validates that signature against the
|
|
1642
|
+
* owner through ERC-1271 on each of them. A chain where the owner has no code
|
|
1643
|
+
* would accept the signature nowhere, so refuse rather than sign it.
|
|
1644
|
+
*
|
|
1645
|
+
* The session list is not filtered here: the execution API rebuilds the digest
|
|
1646
|
+
* from its own configuration, so dropping a chain client-side would change the
|
|
1647
|
+
* hash and the signature would be rejected everywhere.
|
|
1648
|
+
* @private
|
|
1649
|
+
*/
|
|
1650
|
+
private assertOwnerSafeOnSessionChains;
|
|
1628
1651
|
private signSessionKey;
|
|
1629
1652
|
/**
|
|
1630
1653
|
* Patch the user's protocol selection on USDC, WETH, and EURC across all
|
|
@@ -3312,6 +3335,139 @@ declare function createBankrProvider(config: BankrProviderConfig): {
|
|
|
3312
3335
|
};
|
|
3313
3336
|
type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
3314
3337
|
|
|
3338
|
+
/**
|
|
3339
|
+
* EIP-1193 provider for a threshold-1 parent Safe.
|
|
3340
|
+
*
|
|
3341
|
+
* The owner is the wallet already connected by the integrator (viem wallet
|
|
3342
|
+
* client, local account, or EIP-1193 provider). A 2-of-4 Safe connects through
|
|
3343
|
+
* WalletConnect or the Safe App instead, because one signer cannot execute it.
|
|
3344
|
+
*/
|
|
3345
|
+
|
|
3346
|
+
/**
|
|
3347
|
+
* EIP-1193 wallet, such as an injected provider or WalletConnect.
|
|
3348
|
+
*/
|
|
3349
|
+
interface SafeOwnerEip1193 {
|
|
3350
|
+
/**
|
|
3351
|
+
* JSON-RPC request on the owner wallet.
|
|
3352
|
+
*
|
|
3353
|
+
* @param args - Method and optional params.
|
|
3354
|
+
* @returns The wallet's RPC result.
|
|
3355
|
+
*/
|
|
3356
|
+
request: (args: {
|
|
3357
|
+
method: string;
|
|
3358
|
+
params?: readonly unknown[] | undefined;
|
|
3359
|
+
}) => Promise<unknown>;
|
|
3360
|
+
}
|
|
3361
|
+
/**
|
|
3362
|
+
* Owner wallet used to sign Safe hashes and pay gas for `execTransaction`.
|
|
3363
|
+
* Pass the wallet the integrator already connected. A raw private key is not required.
|
|
3364
|
+
*/
|
|
3365
|
+
type SafeOwnerWallet = Account | WalletClient | SafeOwnerEip1193;
|
|
3366
|
+
/**
|
|
3367
|
+
* Arguments for {@link createSafeOwnerProvider}.
|
|
3368
|
+
*
|
|
3369
|
+
* @remarks
|
|
3370
|
+
* The Safe must be deployed on `chain` and its threshold must be 1. `owner` is
|
|
3371
|
+
* that owner's existing wallet. For a 2-of-4 treasury, connect the Safe itself
|
|
3372
|
+
* with WalletConnect or the Safe App and pass that provider to
|
|
3373
|
+
* {@link ZyfaiSDK.connectAccount}. One signer cannot execute a 2-of-4.
|
|
3374
|
+
*/
|
|
3375
|
+
interface SafeOwnerProviderConfig {
|
|
3376
|
+
/**
|
|
3377
|
+
* Parent Safe that becomes the connected account and the `userAddress` on
|
|
3378
|
+
* `sendDeposit` and `withdrawFunds`.
|
|
3379
|
+
*/
|
|
3380
|
+
safeAddress: Address$1;
|
|
3381
|
+
/**
|
|
3382
|
+
* Wallet of an owner of `safeAddress`. A viem wallet client, a local account,
|
|
3383
|
+
* or an EIP-1193 provider. This wallet pays gas when the threshold is 1.
|
|
3384
|
+
*/
|
|
3385
|
+
owner: SafeOwnerWallet;
|
|
3386
|
+
/** Chain where `safeAddress` has contract code. A Safe on Ethereum is not usable on Base. */
|
|
3387
|
+
chain: Chain;
|
|
3388
|
+
}
|
|
3389
|
+
/**
|
|
3390
|
+
* EIP-1193 provider whose accounts are the parent Safe, not the owner EOA.
|
|
3391
|
+
*
|
|
3392
|
+
* @remarks
|
|
3393
|
+
* `eth_requestAccounts` returns the Safe. `personal_sign` and
|
|
3394
|
+
* `eth_signTypedData_v4` produce signatures the Safe accepts via `isValidSignature`.
|
|
3395
|
+
* `eth_sendTransaction` calls `execTransaction` and waits for the receipt.
|
|
3396
|
+
* Pass this object to {@link ZyfaiSDK.connectAccount}.
|
|
3397
|
+
*/
|
|
3398
|
+
interface SafeOwnerProvider {
|
|
3399
|
+
/**
|
|
3400
|
+
* JSON-RPC entry used by viem when the SDK signs or sends.
|
|
3401
|
+
*
|
|
3402
|
+
* @param args - Method name (`eth_requestAccounts`, `personal_sign`, `eth_signTypedData_v4`, `eth_sendTransaction`) and optional params.
|
|
3403
|
+
* @returns Accounts, a signature, or the executed transaction hash.
|
|
3404
|
+
*/
|
|
3405
|
+
request: (args: {
|
|
3406
|
+
method: string;
|
|
3407
|
+
params?: readonly unknown[] | undefined;
|
|
3408
|
+
}) => Promise<unknown>;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* Create an EIP-1193 provider that signs and executes as a threshold-1 Safe.
|
|
3412
|
+
*
|
|
3413
|
+
* @remarks
|
|
3414
|
+
* Pass the provider to {@link ZyfaiSDK.connectAccount}. The address it returns
|
|
3415
|
+
* is the Safe. Pass that same address as `userAddress` on
|
|
3416
|
+
* {@link ZyfaiSDK.sendDeposit} and {@link ZyfaiSDK.withdrawFunds}. Withdrawals
|
|
3417
|
+
* settle to the Safe. The owner wallet pays gas for `execTransaction`.
|
|
3418
|
+
*
|
|
3419
|
+
* This helper is only for threshold 1. A 2-of-4 Safe (four owners, two
|
|
3420
|
+
* signatures required) must be connected with WalletConnect or the Safe App.
|
|
3421
|
+
* That wallet collects the second signature. `sendDeposit` then proposes the
|
|
3422
|
+
* transfer from the parent Safe and polls Safe Transaction Service until the
|
|
3423
|
+
* co-signers execute it. Do not pass one signer of a 2-of-4 to this function.
|
|
3424
|
+
*
|
|
3425
|
+
* @param config - Safe address, the owner wallet, and the chain where the Safe is deployed.
|
|
3426
|
+
* @returns A provider whose account is `config.safeAddress`.
|
|
3427
|
+
*
|
|
3428
|
+
* @throws If `safeAddress` is not an address, or `owner` is not a wallet client, account, or EIP-1193 provider.
|
|
3429
|
+
* @throws If the Safe has no code on `config.chain`. Choose the chain where the Safe was deployed.
|
|
3430
|
+
* @throws If the threshold is above 1. Connect a 2-of-4 through its wallet provider.
|
|
3431
|
+
* @throws If the wallet address is not an owner of the Safe.
|
|
3432
|
+
* @throws If `isValidSignature` rejects the owner signature.
|
|
3433
|
+
*
|
|
3434
|
+
* @example
|
|
3435
|
+
* ```typescript
|
|
3436
|
+
* import { createSafeOwnerProvider, ZyfaiSDK } from "@zyfai/sdk";
|
|
3437
|
+
* import { createWalletClient, custom } from "viem";
|
|
3438
|
+
* import { base } from "viem/chains";
|
|
3439
|
+
*
|
|
3440
|
+
* // Threshold-1 Safe. `owner` is the wallet the user already connected.
|
|
3441
|
+
* const owner = createWalletClient({
|
|
3442
|
+
* chain: base,
|
|
3443
|
+
* transport: custom(window.ethereum),
|
|
3444
|
+
* });
|
|
3445
|
+
* const provider = await createSafeOwnerProvider({
|
|
3446
|
+
* safeAddress: "0xParentSafe",
|
|
3447
|
+
* owner,
|
|
3448
|
+
* chain: base,
|
|
3449
|
+
* });
|
|
3450
|
+
* const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY! });
|
|
3451
|
+
* const parent = await sdk.connectAccount(provider, 8453);
|
|
3452
|
+
* const sent = await sdk.sendDeposit(parent, 8453, "100000", "USDC");
|
|
3453
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
3454
|
+
* ```
|
|
3455
|
+
*
|
|
3456
|
+
* @example
|
|
3457
|
+
* ```typescript
|
|
3458
|
+
* // 2-of-4 treasury. Do not use createSafeOwnerProvider.
|
|
3459
|
+
* // safeWalletProvider is WalletConnect or the Safe App, connected as the Safe.
|
|
3460
|
+
* const parent = await sdk.connectAccount(safeWalletProvider, 1);
|
|
3461
|
+
* const sent = await sdk.sendDeposit(parent, 1, "1000000", "USDC");
|
|
3462
|
+
* // Returns after another owner executes the Safe transaction.
|
|
3463
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 1);
|
|
3464
|
+
* ```
|
|
3465
|
+
*
|
|
3466
|
+
* @see ZyfaiSDK.connectAccount
|
|
3467
|
+
* @see ZyfaiSDK.sendDeposit
|
|
3468
|
+
*/
|
|
3469
|
+
declare function createSafeOwnerProvider(config: SafeOwnerProviderConfig): Promise<SafeOwnerProvider>;
|
|
3470
|
+
|
|
3315
3471
|
/**
|
|
3316
3472
|
* Assets the agent manages for pause, resume, first-deposit protocol setup,
|
|
3317
3473
|
* and bulk strategy changes. Derived from {@link ASSET_CONFIGS} where
|
|
@@ -3467,4 +3623,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
3467
3623
|
*/
|
|
3468
3624
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
3469
3625
|
|
|
3470
|
-
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 BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DecodedUserOperationCall, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ENTRY_POINT_V07_ADDRESS, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetAvailablePoolsOptions, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, 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, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, 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, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, 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 SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, type V1ChainSessions, type V1SessionEnableInput, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VerifiableUserOperation, type VolumeAssetType, 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, buildV1ChainSessions, createBankrProvider, decodeUserOperationCalls, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, hashUserOperationV07, hashV1SessionEnable, isSupportedChain, parseUserOperationJson, parseV1ChainSessions, resolveDepositRoute, resolveRelaySlippageBps, serializeV1ChainSessions, type staleBalances };
|
|
3626
|
+
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 BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DecodedUserOperationCall, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ENTRY_POINT_V07_ADDRESS, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetAvailablePoolsOptions, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, 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, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, 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, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, 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 SafeOwnerEip1193, type SafeOwnerProvider, type SafeOwnerProviderConfig, type SafeOwnerWallet, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, type V1ChainSessions, type V1SessionEnableInput, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VerifiableUserOperation, type VolumeAssetType, 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, buildV1ChainSessions, createBankrProvider, createSafeOwnerProvider, decodeUserOperationCalls, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, hashUserOperationV07, hashV1SessionEnable, isSupportedChain, parseUserOperationJson, parseV1ChainSessions, resolveDepositRoute, resolveRelaySlippageBps, serializeV1ChainSessions, type staleBalances };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, PublicClient, Address as Address$1, Hex as Hex$1 } from 'viem';
|
|
1
|
+
import { Chain, PublicClient, Address as Address$1, Hex as Hex$1, Account, WalletClient } from 'viem';
|
|
2
2
|
import { hashChainSessions } from '@rhinestone/module-sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1294,11 +1294,15 @@ declare class ZyfaiSDK {
|
|
|
1294
1294
|
signature: Hex;
|
|
1295
1295
|
origin?: string;
|
|
1296
1296
|
}): Promise<LoginResponse>;
|
|
1297
|
+
/** Warn that a deprecated compatibility method was called. */
|
|
1298
|
+
private warnDeprecatedOnboardingMethod;
|
|
1297
1299
|
/**
|
|
1298
|
-
* Warn
|
|
1299
|
-
*
|
|
1300
|
+
* Warn only a pool wallet, which sendDeposit onboards on its own. A contract
|
|
1301
|
+
* owner is never predeployed and reaches these methods through sendDeposit,
|
|
1302
|
+
* so warning unconditionally tells that caller to use what it just called.
|
|
1303
|
+
* Call after authentication, once `isPredeployed` is resolved.
|
|
1300
1304
|
*/
|
|
1301
|
-
private
|
|
1305
|
+
private warnPredeployedOnboardingMethod;
|
|
1302
1306
|
private readonly executionApiUrl;
|
|
1303
1307
|
private readonly bypassMinPortfolio;
|
|
1304
1308
|
/**
|
|
@@ -1542,6 +1546,11 @@ declare class ZyfaiSDK {
|
|
|
1542
1546
|
* from the user record before allowing a transfer to an undeployed pool Safe.
|
|
1543
1547
|
* @private
|
|
1544
1548
|
*/
|
|
1549
|
+
/**
|
|
1550
|
+
* Deploy the child Zyfai Safe and session for a nested (contract) owner.
|
|
1551
|
+
* @private
|
|
1552
|
+
*/
|
|
1553
|
+
private ensureNestedOwnerReadyForDeposit;
|
|
1545
1554
|
private hydrateSessionWallet;
|
|
1546
1555
|
/**
|
|
1547
1556
|
* Resolve the Safe address: backend-assigned for the connected predeployed
|
|
@@ -1569,9 +1578,10 @@ declare class ZyfaiSDK {
|
|
|
1569
1578
|
/**
|
|
1570
1579
|
* Deploy Safe Smart Wallet for a user
|
|
1571
1580
|
*
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1574
|
-
* legacy
|
|
1581
|
+
* Not needed for a predeployed (pool) wallet: {@link ZyfaiSDK.sendDeposit} deploys the Safe and
|
|
1582
|
+
* enables the agent session on first deposit. Required for an owner that is not predeployed —
|
|
1583
|
+
* a contract owner such as a nested Safe, or a legacy self-deployed wallet — where `sendDeposit`
|
|
1584
|
+
* calls this method internally.
|
|
1575
1585
|
*
|
|
1576
1586
|
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1577
1587
|
*
|
|
@@ -1585,11 +1595,11 @@ declare class ZyfaiSDK {
|
|
|
1585
1595
|
*
|
|
1586
1596
|
* @example
|
|
1587
1597
|
* ```typescript
|
|
1588
|
-
* // Preferred: sendDeposit handles
|
|
1598
|
+
* // Preferred: sendDeposit handles onboarding for every owner type
|
|
1589
1599
|
* const sent = await sdk.sendDeposit(userAddress, 8453, amount, "USDC");
|
|
1590
1600
|
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1591
1601
|
*
|
|
1592
|
-
* //
|
|
1602
|
+
* // Explicit: deploy with default conservative strategy
|
|
1593
1603
|
* await sdk.deploySafe(userAddress, 8453);
|
|
1594
1604
|
* ```
|
|
1595
1605
|
*/
|
|
@@ -1598,9 +1608,10 @@ declare class ZyfaiSDK {
|
|
|
1598
1608
|
* Create session key with auto-fetched configuration from Zyfai API
|
|
1599
1609
|
* This is the simplified method that automatically fetches session configuration
|
|
1600
1610
|
*
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1603
|
-
*
|
|
1611
|
+
* Not needed for a predeployed (pool) wallet: its agent session is already enabled on-chain and
|
|
1612
|
+
* {@link ZyfaiSDK.sendDeposit} records it after the first deposit. Required for an owner that is
|
|
1613
|
+
* not predeployed — a contract owner such as a nested Safe, or a legacy self-deployed wallet —
|
|
1614
|
+
* where `sendDeposit` calls this method internally.
|
|
1604
1615
|
*
|
|
1605
1616
|
* @see {@link ZyfaiSDK.sendDeposit}
|
|
1606
1617
|
*
|
|
@@ -1612,11 +1623,11 @@ declare class ZyfaiSDK {
|
|
|
1612
1623
|
*
|
|
1613
1624
|
* @example
|
|
1614
1625
|
* ```typescript
|
|
1615
|
-
* // Preferred: sendDeposit handles session onboarding for
|
|
1626
|
+
* // Preferred: sendDeposit handles session onboarding for every owner type
|
|
1616
1627
|
* const sent = await sdk.sendDeposit(userAddress, 8453, amount, "USDC");
|
|
1617
1628
|
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
1618
1629
|
*
|
|
1619
|
-
* //
|
|
1630
|
+
* // Explicit:
|
|
1620
1631
|
* const result = await sdk.createSessionKey(userAddress, 8453);
|
|
1621
1632
|
* ```
|
|
1622
1633
|
*/
|
|
@@ -1625,6 +1636,18 @@ declare class ZyfaiSDK {
|
|
|
1625
1636
|
* Internal method to sign session key
|
|
1626
1637
|
* @private
|
|
1627
1638
|
*/
|
|
1639
|
+
/**
|
|
1640
|
+
* A nested Safe owner signs one MultiChainSession covering every chain in the
|
|
1641
|
+
* session configuration, and the child validates that signature against the
|
|
1642
|
+
* owner through ERC-1271 on each of them. A chain where the owner has no code
|
|
1643
|
+
* would accept the signature nowhere, so refuse rather than sign it.
|
|
1644
|
+
*
|
|
1645
|
+
* The session list is not filtered here: the execution API rebuilds the digest
|
|
1646
|
+
* from its own configuration, so dropping a chain client-side would change the
|
|
1647
|
+
* hash and the signature would be rejected everywhere.
|
|
1648
|
+
* @private
|
|
1649
|
+
*/
|
|
1650
|
+
private assertOwnerSafeOnSessionChains;
|
|
1628
1651
|
private signSessionKey;
|
|
1629
1652
|
/**
|
|
1630
1653
|
* Patch the user's protocol selection on USDC, WETH, and EURC across all
|
|
@@ -3312,6 +3335,139 @@ declare function createBankrProvider(config: BankrProviderConfig): {
|
|
|
3312
3335
|
};
|
|
3313
3336
|
type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
3314
3337
|
|
|
3338
|
+
/**
|
|
3339
|
+
* EIP-1193 provider for a threshold-1 parent Safe.
|
|
3340
|
+
*
|
|
3341
|
+
* The owner is the wallet already connected by the integrator (viem wallet
|
|
3342
|
+
* client, local account, or EIP-1193 provider). A 2-of-4 Safe connects through
|
|
3343
|
+
* WalletConnect or the Safe App instead, because one signer cannot execute it.
|
|
3344
|
+
*/
|
|
3345
|
+
|
|
3346
|
+
/**
|
|
3347
|
+
* EIP-1193 wallet, such as an injected provider or WalletConnect.
|
|
3348
|
+
*/
|
|
3349
|
+
interface SafeOwnerEip1193 {
|
|
3350
|
+
/**
|
|
3351
|
+
* JSON-RPC request on the owner wallet.
|
|
3352
|
+
*
|
|
3353
|
+
* @param args - Method and optional params.
|
|
3354
|
+
* @returns The wallet's RPC result.
|
|
3355
|
+
*/
|
|
3356
|
+
request: (args: {
|
|
3357
|
+
method: string;
|
|
3358
|
+
params?: readonly unknown[] | undefined;
|
|
3359
|
+
}) => Promise<unknown>;
|
|
3360
|
+
}
|
|
3361
|
+
/**
|
|
3362
|
+
* Owner wallet used to sign Safe hashes and pay gas for `execTransaction`.
|
|
3363
|
+
* Pass the wallet the integrator already connected. A raw private key is not required.
|
|
3364
|
+
*/
|
|
3365
|
+
type SafeOwnerWallet = Account | WalletClient | SafeOwnerEip1193;
|
|
3366
|
+
/**
|
|
3367
|
+
* Arguments for {@link createSafeOwnerProvider}.
|
|
3368
|
+
*
|
|
3369
|
+
* @remarks
|
|
3370
|
+
* The Safe must be deployed on `chain` and its threshold must be 1. `owner` is
|
|
3371
|
+
* that owner's existing wallet. For a 2-of-4 treasury, connect the Safe itself
|
|
3372
|
+
* with WalletConnect or the Safe App and pass that provider to
|
|
3373
|
+
* {@link ZyfaiSDK.connectAccount}. One signer cannot execute a 2-of-4.
|
|
3374
|
+
*/
|
|
3375
|
+
interface SafeOwnerProviderConfig {
|
|
3376
|
+
/**
|
|
3377
|
+
* Parent Safe that becomes the connected account and the `userAddress` on
|
|
3378
|
+
* `sendDeposit` and `withdrawFunds`.
|
|
3379
|
+
*/
|
|
3380
|
+
safeAddress: Address$1;
|
|
3381
|
+
/**
|
|
3382
|
+
* Wallet of an owner of `safeAddress`. A viem wallet client, a local account,
|
|
3383
|
+
* or an EIP-1193 provider. This wallet pays gas when the threshold is 1.
|
|
3384
|
+
*/
|
|
3385
|
+
owner: SafeOwnerWallet;
|
|
3386
|
+
/** Chain where `safeAddress` has contract code. A Safe on Ethereum is not usable on Base. */
|
|
3387
|
+
chain: Chain;
|
|
3388
|
+
}
|
|
3389
|
+
/**
|
|
3390
|
+
* EIP-1193 provider whose accounts are the parent Safe, not the owner EOA.
|
|
3391
|
+
*
|
|
3392
|
+
* @remarks
|
|
3393
|
+
* `eth_requestAccounts` returns the Safe. `personal_sign` and
|
|
3394
|
+
* `eth_signTypedData_v4` produce signatures the Safe accepts via `isValidSignature`.
|
|
3395
|
+
* `eth_sendTransaction` calls `execTransaction` and waits for the receipt.
|
|
3396
|
+
* Pass this object to {@link ZyfaiSDK.connectAccount}.
|
|
3397
|
+
*/
|
|
3398
|
+
interface SafeOwnerProvider {
|
|
3399
|
+
/**
|
|
3400
|
+
* JSON-RPC entry used by viem when the SDK signs or sends.
|
|
3401
|
+
*
|
|
3402
|
+
* @param args - Method name (`eth_requestAccounts`, `personal_sign`, `eth_signTypedData_v4`, `eth_sendTransaction`) and optional params.
|
|
3403
|
+
* @returns Accounts, a signature, or the executed transaction hash.
|
|
3404
|
+
*/
|
|
3405
|
+
request: (args: {
|
|
3406
|
+
method: string;
|
|
3407
|
+
params?: readonly unknown[] | undefined;
|
|
3408
|
+
}) => Promise<unknown>;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* Create an EIP-1193 provider that signs and executes as a threshold-1 Safe.
|
|
3412
|
+
*
|
|
3413
|
+
* @remarks
|
|
3414
|
+
* Pass the provider to {@link ZyfaiSDK.connectAccount}. The address it returns
|
|
3415
|
+
* is the Safe. Pass that same address as `userAddress` on
|
|
3416
|
+
* {@link ZyfaiSDK.sendDeposit} and {@link ZyfaiSDK.withdrawFunds}. Withdrawals
|
|
3417
|
+
* settle to the Safe. The owner wallet pays gas for `execTransaction`.
|
|
3418
|
+
*
|
|
3419
|
+
* This helper is only for threshold 1. A 2-of-4 Safe (four owners, two
|
|
3420
|
+
* signatures required) must be connected with WalletConnect or the Safe App.
|
|
3421
|
+
* That wallet collects the second signature. `sendDeposit` then proposes the
|
|
3422
|
+
* transfer from the parent Safe and polls Safe Transaction Service until the
|
|
3423
|
+
* co-signers execute it. Do not pass one signer of a 2-of-4 to this function.
|
|
3424
|
+
*
|
|
3425
|
+
* @param config - Safe address, the owner wallet, and the chain where the Safe is deployed.
|
|
3426
|
+
* @returns A provider whose account is `config.safeAddress`.
|
|
3427
|
+
*
|
|
3428
|
+
* @throws If `safeAddress` is not an address, or `owner` is not a wallet client, account, or EIP-1193 provider.
|
|
3429
|
+
* @throws If the Safe has no code on `config.chain`. Choose the chain where the Safe was deployed.
|
|
3430
|
+
* @throws If the threshold is above 1. Connect a 2-of-4 through its wallet provider.
|
|
3431
|
+
* @throws If the wallet address is not an owner of the Safe.
|
|
3432
|
+
* @throws If `isValidSignature` rejects the owner signature.
|
|
3433
|
+
*
|
|
3434
|
+
* @example
|
|
3435
|
+
* ```typescript
|
|
3436
|
+
* import { createSafeOwnerProvider, ZyfaiSDK } from "@zyfai/sdk";
|
|
3437
|
+
* import { createWalletClient, custom } from "viem";
|
|
3438
|
+
* import { base } from "viem/chains";
|
|
3439
|
+
*
|
|
3440
|
+
* // Threshold-1 Safe. `owner` is the wallet the user already connected.
|
|
3441
|
+
* const owner = createWalletClient({
|
|
3442
|
+
* chain: base,
|
|
3443
|
+
* transport: custom(window.ethereum),
|
|
3444
|
+
* });
|
|
3445
|
+
* const provider = await createSafeOwnerProvider({
|
|
3446
|
+
* safeAddress: "0xParentSafe",
|
|
3447
|
+
* owner,
|
|
3448
|
+
* chain: base,
|
|
3449
|
+
* });
|
|
3450
|
+
* const sdk = new ZyfaiSDK({ apiKey: process.env.ZYFAI_API_KEY! });
|
|
3451
|
+
* const parent = await sdk.connectAccount(provider, 8453);
|
|
3452
|
+
* const sent = await sdk.sendDeposit(parent, 8453, "100000", "USDC");
|
|
3453
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 8453);
|
|
3454
|
+
* ```
|
|
3455
|
+
*
|
|
3456
|
+
* @example
|
|
3457
|
+
* ```typescript
|
|
3458
|
+
* // 2-of-4 treasury. Do not use createSafeOwnerProvider.
|
|
3459
|
+
* // safeWalletProvider is WalletConnect or the Safe App, connected as the Safe.
|
|
3460
|
+
* const parent = await sdk.connectAccount(safeWalletProvider, 1);
|
|
3461
|
+
* const sent = await sdk.sendDeposit(parent, 1, "1000000", "USDC");
|
|
3462
|
+
* // Returns after another owner executes the Safe transaction.
|
|
3463
|
+
* await sdk.waitForDepositCredit(sent.registration.id, 1);
|
|
3464
|
+
* ```
|
|
3465
|
+
*
|
|
3466
|
+
* @see ZyfaiSDK.connectAccount
|
|
3467
|
+
* @see ZyfaiSDK.sendDeposit
|
|
3468
|
+
*/
|
|
3469
|
+
declare function createSafeOwnerProvider(config: SafeOwnerProviderConfig): Promise<SafeOwnerProvider>;
|
|
3470
|
+
|
|
3315
3471
|
/**
|
|
3316
3472
|
* Assets the agent manages for pause, resume, first-deposit protocol setup,
|
|
3317
3473
|
* and bulk strategy changes. Derived from {@link ASSET_CONFIGS} where
|
|
@@ -3467,4 +3623,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
3467
3623
|
*/
|
|
3468
3624
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
3469
3625
|
|
|
3470
|
-
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 BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DecodedUserOperationCall, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ENTRY_POINT_V07_ADDRESS, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetAvailablePoolsOptions, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, 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, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, 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, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, 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 SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, type V1ChainSessions, type V1SessionEnableInput, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VerifiableUserOperation, type VolumeAssetType, 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, buildV1ChainSessions, createBankrProvider, decodeUserOperationCalls, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, hashUserOperationV07, hashV1SessionEnable, isSupportedChain, parseUserOperationJson, parseV1ChainSessions, resolveDepositRoute, resolveRelaySlippageBps, serializeV1ChainSessions, type staleBalances };
|
|
3626
|
+
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 BaseMerklCampaignId, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, type ChainTokenEarnings, type CustomizationConfig, type CustomizeBatchRequest, type CustomizeBatchResponse, DATA_API_BASE_URLS, DATA_API_ENDPOINT, DEFAULT_RELAY_SLIPPAGE_BPS, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryPeriod, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DecodedUserOperationCall, type DepegEvent, type DeploySafeResponse, type DepositLifecycleResponse, type DepositLifecycleStatus, type DepositPositionOutcome, type DepositResponse, type DepositRoute, type DepositRouteInput, ENTRY_POINT_V07_ADDRESS, ERC7579_LAUNCHPAD_ADDRESS, type ERC7739Context, type ERC7739Data, EXECUTION_API_BASE_URLS, type ExcludedPool, type FirstPermitDepositStatus, type FirstTopupResponse, type GetAvailablePoolsOptions, type GetPoolsResponse, type GetSelectedPoolsResponse, type Hex, type HistoryAssetType, 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, MAX_RELAY_SLIPPAGE_BPS, type MerklCampaign, 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, RELAY_SLIPPAGE_PRESETS_BPS, type RebalanceFrequencyResponse, type RegisterAgentResponse, type RzfiClaimResponse, type RzfiClaimTransaction, 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 SafeOwnerEip1193, type SafeOwnerProvider, type SafeOwnerProviderConfig, type SafeOwnerWallet, type SdkKeyTVLResponse, type SendDepositParams, type Session, type SessionKeyResponse, type SimulateBestPositionsParams, type SimulateBestPositionsResponse, type SimulateCalldataItem, type SimulatedPosition, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedAsset, type SupportedChainId, type SwapDepositOrder, type SwapDepositParams, type SwapDepositQuote, type TVLResponse, type TokenApy, type TokenEarnings, type UpdateUserProfileRequest, type UpdateUserProfileResponse, type UserPosition, type UserSessionAuth, type V1ChainSessions, type V1SessionEnableInput, VAULT_ADDRESS, type VaultAsset, type VaultClaimResponse, type VaultDepositResponse, type VaultSharesResponse, type VaultWithdrawResponse, type VaultWithdrawStatusResponse, type VerifiableUserOperation, type VolumeAssetType, 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, buildV1ChainSessions, createBankrProvider, createSafeOwnerProvider, decodeUserOperationCalls, getChainConfig, getDataApiBaseUrl, getDefaultTokenAddress, getExecutionApiBaseUrl, getManagedAssets, getSupportedChainIds, getWsUrl, hashUserOperationV07, hashV1SessionEnable, isSupportedChain, parseUserOperationJson, parseV1ChainSessions, resolveDepositRoute, resolveRelaySlippageBps, serializeV1ChainSessions, type staleBalances };
|