@zyfai/sdk 0.5.0 → 0.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 +10 -4
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +166 -21
- package/dist/index.mjs +165 -21
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ Commit the generated file in `.changeset/` with your PR.
|
|
|
45
45
|
|
|
46
46
|
### Publishing (maintainers)
|
|
47
47
|
|
|
48
|
-
After changesets merge to `
|
|
48
|
+
After changesets merge to `release`, a maintainer runs `npm run version-packages` (`changeset version`), then `npm publish`. Details: [`docs/RELEASING.md`](docs/RELEASING.md).
|
|
49
49
|
|
|
50
50
|
## Prerequisites
|
|
51
51
|
|
|
@@ -472,10 +472,10 @@ if (credited.status === "credited") {
|
|
|
472
472
|
- `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
473
|
- If first-deposit protocol patching fails, the transfer still runs. `sendDeposit()` throws if deposit registration is not accepted; retry `logDeposit()` after `connectAccount()`.
|
|
474
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
|
-
- **`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,
|
|
475
|
+
- **`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
476
|
|
|
477
477
|
```typescript
|
|
478
|
-
await sdk.
|
|
478
|
+
await sdk.setStrategyWithProtocols({ strategy: "yieldmaxxing" });
|
|
479
479
|
```
|
|
480
480
|
|
|
481
481
|
#### Deposit With an External Wallet (Sponsored Transactions)
|
|
@@ -1098,9 +1098,15 @@ but the funds are in flight in between. See
|
|
|
1098
1098
|
|
|
1099
1099
|
`updateUserProfile({ asset, strategy })` stores a strategy but does **not**
|
|
1100
1100
|
compute the protocol list that goes with it, so on its own it leaves the asset
|
|
1101
|
-
with nothing to deploy into. `setAssetStrategy` does both in one call
|
|
1101
|
+
with nothing to deploy into. `setAssetStrategy` does both in one call for one
|
|
1102
|
+
asset. `setStrategyWithProtocols` does the same for one asset or for every
|
|
1103
|
+
entry in `getManagedAssets()` when `asset` is omitted:
|
|
1102
1104
|
|
|
1103
1105
|
```typescript
|
|
1106
|
+
const profiles = await sdk.setStrategyWithProtocols({
|
|
1107
|
+
strategy: "yieldmaxxing",
|
|
1108
|
+
});
|
|
1109
|
+
// Or a single asset:
|
|
1104
1110
|
const profile = await sdk.setAssetStrategy({
|
|
1105
1111
|
asset: "NVDAc",
|
|
1106
1112
|
strategy: "yieldmaxxing",
|
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ type Hex = `0x${string}`;
|
|
|
14
14
|
*/
|
|
15
15
|
type Strategy = "conservative" | "aggressive" | "yieldmaxxing";
|
|
16
16
|
/** Public asset symbols supported by the SDK */
|
|
17
|
-
type SupportedAsset = "USDC" | "WETH" | "EURC" | "NVDAc";
|
|
17
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC" | "USDT" | "PYUSD" | "NVDAc";
|
|
18
18
|
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
19
19
|
interface RpcUrlsConfig {
|
|
20
20
|
/** Ethereum mainnet */
|
|
@@ -1474,6 +1474,19 @@ declare class ZyfaiSDK {
|
|
|
1474
1474
|
strategy?: Strategy;
|
|
1475
1475
|
chains?: SupportedChainId[];
|
|
1476
1476
|
}): Promise<UpdateUserProfileResponse>;
|
|
1477
|
+
/**
|
|
1478
|
+
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
1479
|
+
* assets ({@link getManagedAssets}). Prefer this over
|
|
1480
|
+
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
1481
|
+
* with the tier (including `yieldmaxxing` async venues).
|
|
1482
|
+
*
|
|
1483
|
+
* @group Portfolio and execution
|
|
1484
|
+
*/
|
|
1485
|
+
setStrategyWithProtocols(params: {
|
|
1486
|
+
strategy: Strategy;
|
|
1487
|
+
asset?: SupportedAsset;
|
|
1488
|
+
chains?: SupportedChainId[];
|
|
1489
|
+
}): Promise<UpdateUserProfileResponse[]>;
|
|
1477
1490
|
/**
|
|
1478
1491
|
* Drop protocols that have no pools on any of the selected chains for the
|
|
1479
1492
|
* requested asset. The /customization/pools endpoint filters server-side on
|
|
@@ -2672,6 +2685,13 @@ declare function createBankrProvider(config: BankrProviderConfig): {
|
|
|
2672
2685
|
};
|
|
2673
2686
|
type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
2674
2687
|
|
|
2688
|
+
/**
|
|
2689
|
+
* Assets the agent manages for pause, resume, first-deposit protocol setup,
|
|
2690
|
+
* and bulk strategy changes. Derived from {@link ASSET_CONFIGS} where
|
|
2691
|
+
* `enabled === true`, with a stable product order for known symbols.
|
|
2692
|
+
*/
|
|
2693
|
+
declare function getManagedAssets(): SupportedAsset[];
|
|
2694
|
+
|
|
2675
2695
|
/**
|
|
2676
2696
|
* API Endpoints Configuration
|
|
2677
2697
|
*
|
|
@@ -2771,4 +2791,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2771
2791
|
*/
|
|
2772
2792
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2773
2793
|
|
|
2774
|
-
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, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ type Hex = `0x${string}`;
|
|
|
14
14
|
*/
|
|
15
15
|
type Strategy = "conservative" | "aggressive" | "yieldmaxxing";
|
|
16
16
|
/** Public asset symbols supported by the SDK */
|
|
17
|
-
type SupportedAsset = "USDC" | "WETH" | "EURC" | "NVDAc";
|
|
17
|
+
type SupportedAsset = "USDC" | "WETH" | "EURC" | "USDT" | "PYUSD" | "NVDAc";
|
|
18
18
|
/** Optional per-chain RPC URLs for on-chain reads and writes. */
|
|
19
19
|
interface RpcUrlsConfig {
|
|
20
20
|
/** Ethereum mainnet */
|
|
@@ -1474,6 +1474,19 @@ declare class ZyfaiSDK {
|
|
|
1474
1474
|
strategy?: Strategy;
|
|
1475
1475
|
chains?: SupportedChainId[];
|
|
1476
1476
|
}): Promise<UpdateUserProfileResponse>;
|
|
1477
|
+
/**
|
|
1478
|
+
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
1479
|
+
* assets ({@link getManagedAssets}). Prefer this over
|
|
1480
|
+
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
1481
|
+
* with the tier (including `yieldmaxxing` async venues).
|
|
1482
|
+
*
|
|
1483
|
+
* @group Portfolio and execution
|
|
1484
|
+
*/
|
|
1485
|
+
setStrategyWithProtocols(params: {
|
|
1486
|
+
strategy: Strategy;
|
|
1487
|
+
asset?: SupportedAsset;
|
|
1488
|
+
chains?: SupportedChainId[];
|
|
1489
|
+
}): Promise<UpdateUserProfileResponse[]>;
|
|
1477
1490
|
/**
|
|
1478
1491
|
* Drop protocols that have no pools on any of the selected chains for the
|
|
1479
1492
|
* requested asset. The /customization/pools endpoint filters server-side on
|
|
@@ -2672,6 +2685,13 @@ declare function createBankrProvider(config: BankrProviderConfig): {
|
|
|
2672
2685
|
};
|
|
2673
2686
|
type BankrProvider = ReturnType<typeof createBankrProvider>;
|
|
2674
2687
|
|
|
2688
|
+
/**
|
|
2689
|
+
* Assets the agent manages for pause, resume, first-deposit protocol setup,
|
|
2690
|
+
* and bulk strategy changes. Derived from {@link ASSET_CONFIGS} where
|
|
2691
|
+
* `enabled === true`, with a stable product order for known symbols.
|
|
2692
|
+
*/
|
|
2693
|
+
declare function getManagedAssets(): SupportedAsset[];
|
|
2694
|
+
|
|
2675
2695
|
/**
|
|
2676
2696
|
* API Endpoints Configuration
|
|
2677
2697
|
*
|
|
@@ -2771,4 +2791,4 @@ declare const ERC7579_LAUNCHPAD_ADDRESS: Address$1;
|
|
|
2771
2791
|
*/
|
|
2772
2792
|
declare const POOL_MODULE_ADDRESSES: readonly Address$1[];
|
|
2773
2793
|
|
|
2774
|
-
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, getSupportedChainIds, getWsUrl, isSupportedChain, type staleBalances };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __export(index_exports, {
|
|
|
60
60
|
getDataApiBaseUrl: () => getDataApiBaseUrl,
|
|
61
61
|
getDefaultTokenAddress: () => getDefaultTokenAddress,
|
|
62
62
|
getExecutionApiBaseUrl: () => getExecutionApiBaseUrl,
|
|
63
|
+
getManagedAssets: () => getManagedAssets,
|
|
63
64
|
getSupportedChainIds: () => getSupportedChainIds,
|
|
64
65
|
getWsUrl: () => getWsUrl,
|
|
65
66
|
isSupportedChain: () => isSupportedChain
|
|
@@ -547,6 +548,33 @@ var ERC20_ABI = [
|
|
|
547
548
|
outputs: [{ name: "", type: "uint256" }]
|
|
548
549
|
}
|
|
549
550
|
];
|
|
551
|
+
var ERC20_TRANSFER_LEGACY_ABI = [
|
|
552
|
+
{
|
|
553
|
+
name: "transfer",
|
|
554
|
+
type: "function",
|
|
555
|
+
stateMutability: "nonpayable",
|
|
556
|
+
inputs: [
|
|
557
|
+
{ name: "to", type: "address" },
|
|
558
|
+
{ name: "amount", type: "uint256" }
|
|
559
|
+
],
|
|
560
|
+
outputs: []
|
|
561
|
+
}
|
|
562
|
+
];
|
|
563
|
+
var ERC20_TRANSFER_WITH_BOOL_ABI = [
|
|
564
|
+
{
|
|
565
|
+
name: "transfer",
|
|
566
|
+
type: "function",
|
|
567
|
+
stateMutability: "nonpayable",
|
|
568
|
+
inputs: [
|
|
569
|
+
{ name: "to", type: "address" },
|
|
570
|
+
{ name: "amount", type: "uint256" }
|
|
571
|
+
],
|
|
572
|
+
outputs: [{ name: "", type: "bool" }]
|
|
573
|
+
}
|
|
574
|
+
];
|
|
575
|
+
function erc20TransferWriteAbi(assetSymbol) {
|
|
576
|
+
return assetSymbol === "USDT" ? ERC20_TRANSFER_LEGACY_ABI : ERC20_TRANSFER_WITH_BOOL_ABI;
|
|
577
|
+
}
|
|
550
578
|
var IDENTITY_REGISTRY_ABI = (0, import_viem.parseAbi)([
|
|
551
579
|
"function register() external returns (uint256 agentId)",
|
|
552
580
|
"function register(string tokenUri) external returns (uint256 agentId)",
|
|
@@ -644,8 +672,12 @@ var MIN_PORTFOLIO_BALANCE = {
|
|
|
644
672
|
1: {
|
|
645
673
|
USDC: 10000n * 10n ** 6n,
|
|
646
674
|
// 10,000 USDC (6 decimals)
|
|
647
|
-
EURC: 10000n * 10n ** 6n
|
|
675
|
+
EURC: 10000n * 10n ** 6n,
|
|
648
676
|
// 10,000 EURC (6 decimals)
|
|
677
|
+
USDT: 10000n * 10n ** 6n,
|
|
678
|
+
// 10,000 USDT (6 decimals)
|
|
679
|
+
PYUSD: 10000n * 10n ** 6n
|
|
680
|
+
// 10,000 PYUSD (6 decimals)
|
|
649
681
|
},
|
|
650
682
|
8453: {
|
|
651
683
|
USDC: 10n * 10n ** 6n,
|
|
@@ -745,7 +777,7 @@ var ASSET_CONFIGS = {
|
|
|
745
777
|
displayName: "USDC",
|
|
746
778
|
icon: "/ai-dashboard/usdc-token.png",
|
|
747
779
|
decimals: 6,
|
|
748
|
-
tokenSymbols: ["USDC", "USDC.e", "
|
|
780
|
+
tokenSymbols: ["USDC", "USDC.e", "USDT0"],
|
|
749
781
|
tokenSymbolsByChainId: {
|
|
750
782
|
1: "USDC",
|
|
751
783
|
8453: "USDC",
|
|
@@ -816,6 +848,36 @@ var ASSET_CONFIGS = {
|
|
|
816
848
|
},
|
|
817
849
|
enabled: true
|
|
818
850
|
},
|
|
851
|
+
USDT: {
|
|
852
|
+
symbol: "USDT",
|
|
853
|
+
assetType: "usdt",
|
|
854
|
+
displayName: "USDT",
|
|
855
|
+
icon: "https://etherscan.io/token/images/tethernew_32.svg",
|
|
856
|
+
decimals: 6,
|
|
857
|
+
tokenSymbols: ["USDT"],
|
|
858
|
+
tokenSymbolsByChainId: {
|
|
859
|
+
1: "USDT"
|
|
860
|
+
},
|
|
861
|
+
addresses: {
|
|
862
|
+
1: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
|
863
|
+
},
|
|
864
|
+
enabled: true
|
|
865
|
+
},
|
|
866
|
+
PYUSD: {
|
|
867
|
+
symbol: "PYUSD",
|
|
868
|
+
assetType: "pyusd",
|
|
869
|
+
displayName: "PYUSD",
|
|
870
|
+
icon: "https://etherscan.io/token/images/PYUSD_32.png",
|
|
871
|
+
decimals: 6,
|
|
872
|
+
tokenSymbols: ["PYUSD"],
|
|
873
|
+
tokenSymbolsByChainId: {
|
|
874
|
+
1: "PYUSD"
|
|
875
|
+
},
|
|
876
|
+
addresses: {
|
|
877
|
+
1: "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"
|
|
878
|
+
},
|
|
879
|
+
enabled: true
|
|
880
|
+
},
|
|
819
881
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
820
882
|
// protocols with delayed withdrawals — see the `yieldmaxxing` strategy.
|
|
821
883
|
NVDAc: {
|
|
@@ -890,6 +952,24 @@ var getSupportedChainIds = () => {
|
|
|
890
952
|
return Object.keys(CHAINS).map(Number);
|
|
891
953
|
};
|
|
892
954
|
|
|
955
|
+
// src/config/managed-assets.ts
|
|
956
|
+
var MANAGED_ASSET_ORDER = [
|
|
957
|
+
"USDC",
|
|
958
|
+
"WETH",
|
|
959
|
+
"EURC",
|
|
960
|
+
"USDT",
|
|
961
|
+
"PYUSD",
|
|
962
|
+
"NVDAc"
|
|
963
|
+
];
|
|
964
|
+
function getManagedAssets() {
|
|
965
|
+
const enabled = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([key]) => key);
|
|
966
|
+
const ordered = MANAGED_ASSET_ORDER.filter(
|
|
967
|
+
(symbol) => enabled.includes(symbol)
|
|
968
|
+
);
|
|
969
|
+
const remainder = enabled.filter((symbol) => !MANAGED_ASSET_ORDER.includes(symbol)).sort((a, b) => a.localeCompare(b));
|
|
970
|
+
return [...ordered, ...remainder];
|
|
971
|
+
}
|
|
972
|
+
|
|
893
973
|
// src/utils/safe-account.ts
|
|
894
974
|
var import_module_sdk = require("@rhinestone/module-sdk");
|
|
895
975
|
var import_accounts = require("permissionless/accounts");
|
|
@@ -1123,7 +1203,7 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1123
1203
|
|
|
1124
1204
|
// src/utils/strategy.ts
|
|
1125
1205
|
var PUBLIC_STRATEGIES = `"conservative", "aggressive" or "yieldmaxxing"`;
|
|
1126
|
-
var SUPPORTED_ASSETS = `"
|
|
1206
|
+
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1127
1207
|
function toInternalStrategy(publicStrategy) {
|
|
1128
1208
|
switch (publicStrategy) {
|
|
1129
1209
|
case "conservative":
|
|
@@ -1203,20 +1283,12 @@ function removeUnusedFields(obj) {
|
|
|
1203
1283
|
return result;
|
|
1204
1284
|
}
|
|
1205
1285
|
function convertAssetInternally(asset) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
if (asset === "WETH") {
|
|
1210
|
-
return "eth";
|
|
1211
|
-
}
|
|
1212
|
-
if (asset === "EURC") {
|
|
1213
|
-
return "eurc";
|
|
1214
|
-
}
|
|
1215
|
-
if (asset === "NVDAc") {
|
|
1216
|
-
return "nvdac";
|
|
1286
|
+
const assetType = ASSET_CONFIGS[asset]?.assetType;
|
|
1287
|
+
if (assetType === "usdc" || assetType === "eth" || assetType === "eurc" || assetType === "usdt" || assetType === "pyusd" || assetType === "nvdac") {
|
|
1288
|
+
return assetType;
|
|
1217
1289
|
}
|
|
1218
1290
|
throw new Error(
|
|
1219
|
-
`Invalid asset: ${asset}. Must be ${SUPPORTED_ASSETS}.`
|
|
1291
|
+
`Invalid asset: ${asset}. Must be one of: ${SUPPORTED_ASSETS}.`
|
|
1220
1292
|
);
|
|
1221
1293
|
}
|
|
1222
1294
|
function convertStrategiesToPublic(array) {
|
|
@@ -1672,7 +1744,6 @@ var AgentDepositIntentTimeoutError = class extends Error {
|
|
|
1672
1744
|
this.name = "AgentDepositIntentTimeoutError";
|
|
1673
1745
|
}
|
|
1674
1746
|
};
|
|
1675
|
-
var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
|
|
1676
1747
|
var _ZyfaiSDK = class _ZyfaiSDK {
|
|
1677
1748
|
/**
|
|
1678
1749
|
* Create an SDK instance bound to a partner API key.
|
|
@@ -1978,7 +2049,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1978
2049
|
async pauseAgent() {
|
|
1979
2050
|
try {
|
|
1980
2051
|
let latest;
|
|
1981
|
-
for (const asset of
|
|
2052
|
+
for (const asset of getManagedAssets()) {
|
|
1982
2053
|
latest = await this.updateUserProfile({ asset, protocols: [] });
|
|
1983
2054
|
}
|
|
1984
2055
|
if (!latest) {
|
|
@@ -2017,7 +2088,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2017
2088
|
ENDPOINTS.PROTOCOLS()
|
|
2018
2089
|
);
|
|
2019
2090
|
let latest;
|
|
2020
|
-
for (const asset of
|
|
2091
|
+
for (const asset of getManagedAssets()) {
|
|
2021
2092
|
latest = await this.updateUserProtocolsForAsset(
|
|
2022
2093
|
asset,
|
|
2023
2094
|
getAssetChainIds(asset),
|
|
@@ -2796,7 +2867,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2796
2867
|
const allProtocols = await this.httpClient.get(
|
|
2797
2868
|
ENDPOINTS.PROTOCOLS()
|
|
2798
2869
|
);
|
|
2799
|
-
for (const asset of
|
|
2870
|
+
for (const asset of getManagedAssets()) {
|
|
2800
2871
|
try {
|
|
2801
2872
|
await this.updateUserProtocolsForAsset(
|
|
2802
2873
|
asset,
|
|
@@ -2969,6 +3040,77 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2969
3040
|
);
|
|
2970
3041
|
}
|
|
2971
3042
|
}
|
|
3043
|
+
/**
|
|
3044
|
+
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
3045
|
+
* assets ({@link getManagedAssets}). Prefer this over
|
|
3046
|
+
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
3047
|
+
* with the tier (including `yieldmaxxing` async venues).
|
|
3048
|
+
*
|
|
3049
|
+
* @group Portfolio and execution
|
|
3050
|
+
*/
|
|
3051
|
+
async setStrategyWithProtocols(params) {
|
|
3052
|
+
const { strategy, asset, chains } = params;
|
|
3053
|
+
if (!isValidPublicStrategy(strategy)) {
|
|
3054
|
+
throw new Error(
|
|
3055
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
3056
|
+
);
|
|
3057
|
+
}
|
|
3058
|
+
const assets = asset ? [asset] : getManagedAssets();
|
|
3059
|
+
if (assets.length === 0) {
|
|
3060
|
+
throw new Error("No managed assets available to configure.");
|
|
3061
|
+
}
|
|
3062
|
+
const plannedUpdates = [];
|
|
3063
|
+
const validationErrors = [];
|
|
3064
|
+
for (const targetAsset of assets) {
|
|
3065
|
+
const supported = getAssetChainIds(targetAsset);
|
|
3066
|
+
if (supported.length === 0) {
|
|
3067
|
+
validationErrors.push(`${targetAsset}: Unsupported asset: ${targetAsset}.`);
|
|
3068
|
+
continue;
|
|
3069
|
+
}
|
|
3070
|
+
const targetChains = chains ?? supported;
|
|
3071
|
+
const unsupported = targetChains.filter((c) => !supported.includes(c));
|
|
3072
|
+
if (unsupported.length > 0) {
|
|
3073
|
+
validationErrors.push(
|
|
3074
|
+
`${targetAsset}: ${targetAsset} is not available on chain ${unsupported.join(
|
|
3075
|
+
", "
|
|
3076
|
+
)}. Supported chains: ${supported.join(", ")}.`
|
|
3077
|
+
);
|
|
3078
|
+
continue;
|
|
3079
|
+
}
|
|
3080
|
+
plannedUpdates.push({ targetAsset, targetChains });
|
|
3081
|
+
}
|
|
3082
|
+
if (validationErrors.length > 0) {
|
|
3083
|
+
throw new Error(
|
|
3084
|
+
`Failed to set strategy with protocols: ${validationErrors.join("; ")}`
|
|
3085
|
+
);
|
|
3086
|
+
}
|
|
3087
|
+
const allProtocols = await this.httpClient.get(
|
|
3088
|
+
ENDPOINTS.PROTOCOLS()
|
|
3089
|
+
);
|
|
3090
|
+
const results = [];
|
|
3091
|
+
const errors = [];
|
|
3092
|
+
for (const { targetAsset, targetChains } of plannedUpdates) {
|
|
3093
|
+
try {
|
|
3094
|
+
const profile = await this.updateUserProtocolsForAsset(
|
|
3095
|
+
targetAsset,
|
|
3096
|
+
targetChains,
|
|
3097
|
+
strategy,
|
|
3098
|
+
allProtocols
|
|
3099
|
+
);
|
|
3100
|
+
results.push(profile);
|
|
3101
|
+
} catch (error) {
|
|
3102
|
+
errors.push(
|
|
3103
|
+
`${targetAsset}: ${error instanceof Error ? error.message : String(error)}`
|
|
3104
|
+
);
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
if (errors.length > 0) {
|
|
3108
|
+
throw new Error(
|
|
3109
|
+
`Failed to set strategy with protocols: ${errors.join("; ")}`
|
|
3110
|
+
);
|
|
3111
|
+
}
|
|
3112
|
+
return results;
|
|
3113
|
+
}
|
|
2972
3114
|
/**
|
|
2973
3115
|
* Drop protocols that have no pools on any of the selected chains for the
|
|
2974
3116
|
* requested asset. The /customization/pools endpoint filters server-side on
|
|
@@ -3099,7 +3241,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3099
3241
|
throw new Error("Valid amount is required");
|
|
3100
3242
|
}
|
|
3101
3243
|
if (!asset) {
|
|
3102
|
-
throw new Error(
|
|
3244
|
+
throw new Error(
|
|
3245
|
+
"Asset is required (USDC, WETH, EURC, USDT, PYUSD, or NVDAc)"
|
|
3246
|
+
);
|
|
3103
3247
|
}
|
|
3104
3248
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3105
3249
|
throw new Error(
|
|
@@ -3175,7 +3319,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3175
3319
|
}
|
|
3176
3320
|
const txHash = await walletClient.writeContract({
|
|
3177
3321
|
address: token,
|
|
3178
|
-
abi:
|
|
3322
|
+
abi: erc20TransferWriteAbi(assetSymbol),
|
|
3179
3323
|
functionName: "transfer",
|
|
3180
3324
|
args: [safeAddress, amountBigInt],
|
|
3181
3325
|
chain: chainConfig.chain,
|
|
@@ -5923,6 +6067,7 @@ function createBankrProvider(config) {
|
|
|
5923
6067
|
getDataApiBaseUrl,
|
|
5924
6068
|
getDefaultTokenAddress,
|
|
5925
6069
|
getExecutionApiBaseUrl,
|
|
6070
|
+
getManagedAssets,
|
|
5926
6071
|
getSupportedChainIds,
|
|
5927
6072
|
getWsUrl,
|
|
5928
6073
|
isSupportedChain
|
package/dist/index.mjs
CHANGED
|
@@ -479,6 +479,33 @@ var ERC20_ABI = [
|
|
|
479
479
|
outputs: [{ name: "", type: "uint256" }]
|
|
480
480
|
}
|
|
481
481
|
];
|
|
482
|
+
var ERC20_TRANSFER_LEGACY_ABI = [
|
|
483
|
+
{
|
|
484
|
+
name: "transfer",
|
|
485
|
+
type: "function",
|
|
486
|
+
stateMutability: "nonpayable",
|
|
487
|
+
inputs: [
|
|
488
|
+
{ name: "to", type: "address" },
|
|
489
|
+
{ name: "amount", type: "uint256" }
|
|
490
|
+
],
|
|
491
|
+
outputs: []
|
|
492
|
+
}
|
|
493
|
+
];
|
|
494
|
+
var ERC20_TRANSFER_WITH_BOOL_ABI = [
|
|
495
|
+
{
|
|
496
|
+
name: "transfer",
|
|
497
|
+
type: "function",
|
|
498
|
+
stateMutability: "nonpayable",
|
|
499
|
+
inputs: [
|
|
500
|
+
{ name: "to", type: "address" },
|
|
501
|
+
{ name: "amount", type: "uint256" }
|
|
502
|
+
],
|
|
503
|
+
outputs: [{ name: "", type: "bool" }]
|
|
504
|
+
}
|
|
505
|
+
];
|
|
506
|
+
function erc20TransferWriteAbi(assetSymbol) {
|
|
507
|
+
return assetSymbol === "USDT" ? ERC20_TRANSFER_LEGACY_ABI : ERC20_TRANSFER_WITH_BOOL_ABI;
|
|
508
|
+
}
|
|
482
509
|
var IDENTITY_REGISTRY_ABI = parseAbi([
|
|
483
510
|
"function register() external returns (uint256 agentId)",
|
|
484
511
|
"function register(string tokenUri) external returns (uint256 agentId)",
|
|
@@ -576,8 +603,12 @@ var MIN_PORTFOLIO_BALANCE = {
|
|
|
576
603
|
1: {
|
|
577
604
|
USDC: 10000n * 10n ** 6n,
|
|
578
605
|
// 10,000 USDC (6 decimals)
|
|
579
|
-
EURC: 10000n * 10n ** 6n
|
|
606
|
+
EURC: 10000n * 10n ** 6n,
|
|
580
607
|
// 10,000 EURC (6 decimals)
|
|
608
|
+
USDT: 10000n * 10n ** 6n,
|
|
609
|
+
// 10,000 USDT (6 decimals)
|
|
610
|
+
PYUSD: 10000n * 10n ** 6n
|
|
611
|
+
// 10,000 PYUSD (6 decimals)
|
|
581
612
|
},
|
|
582
613
|
8453: {
|
|
583
614
|
USDC: 10n * 10n ** 6n,
|
|
@@ -683,7 +714,7 @@ var ASSET_CONFIGS = {
|
|
|
683
714
|
displayName: "USDC",
|
|
684
715
|
icon: "/ai-dashboard/usdc-token.png",
|
|
685
716
|
decimals: 6,
|
|
686
|
-
tokenSymbols: ["USDC", "USDC.e", "
|
|
717
|
+
tokenSymbols: ["USDC", "USDC.e", "USDT0"],
|
|
687
718
|
tokenSymbolsByChainId: {
|
|
688
719
|
1: "USDC",
|
|
689
720
|
8453: "USDC",
|
|
@@ -754,6 +785,36 @@ var ASSET_CONFIGS = {
|
|
|
754
785
|
},
|
|
755
786
|
enabled: true
|
|
756
787
|
},
|
|
788
|
+
USDT: {
|
|
789
|
+
symbol: "USDT",
|
|
790
|
+
assetType: "usdt",
|
|
791
|
+
displayName: "USDT",
|
|
792
|
+
icon: "https://etherscan.io/token/images/tethernew_32.svg",
|
|
793
|
+
decimals: 6,
|
|
794
|
+
tokenSymbols: ["USDT"],
|
|
795
|
+
tokenSymbolsByChainId: {
|
|
796
|
+
1: "USDT"
|
|
797
|
+
},
|
|
798
|
+
addresses: {
|
|
799
|
+
1: "0xdAC17F958D2ee523a2206206994597C13D831ec7"
|
|
800
|
+
},
|
|
801
|
+
enabled: true
|
|
802
|
+
},
|
|
803
|
+
PYUSD: {
|
|
804
|
+
symbol: "PYUSD",
|
|
805
|
+
assetType: "pyusd",
|
|
806
|
+
displayName: "PYUSD",
|
|
807
|
+
icon: "https://etherscan.io/token/images/PYUSD_32.png",
|
|
808
|
+
decimals: 6,
|
|
809
|
+
tokenSymbols: ["PYUSD"],
|
|
810
|
+
tokenSymbolsByChainId: {
|
|
811
|
+
1: "PYUSD"
|
|
812
|
+
},
|
|
813
|
+
addresses: {
|
|
814
|
+
1: "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"
|
|
815
|
+
},
|
|
816
|
+
enabled: true
|
|
817
|
+
},
|
|
757
818
|
// Coinbase B20 tokenized NVIDIA equity. Base only, and only reachable through
|
|
758
819
|
// protocols with delayed withdrawals — see the `yieldmaxxing` strategy.
|
|
759
820
|
NVDAc: {
|
|
@@ -828,6 +889,24 @@ var getSupportedChainIds = () => {
|
|
|
828
889
|
return Object.keys(CHAINS).map(Number);
|
|
829
890
|
};
|
|
830
891
|
|
|
892
|
+
// src/config/managed-assets.ts
|
|
893
|
+
var MANAGED_ASSET_ORDER = [
|
|
894
|
+
"USDC",
|
|
895
|
+
"WETH",
|
|
896
|
+
"EURC",
|
|
897
|
+
"USDT",
|
|
898
|
+
"PYUSD",
|
|
899
|
+
"NVDAc"
|
|
900
|
+
];
|
|
901
|
+
function getManagedAssets() {
|
|
902
|
+
const enabled = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([key]) => key);
|
|
903
|
+
const ordered = MANAGED_ASSET_ORDER.filter(
|
|
904
|
+
(symbol) => enabled.includes(symbol)
|
|
905
|
+
);
|
|
906
|
+
const remainder = enabled.filter((symbol) => !MANAGED_ASSET_ORDER.includes(symbol)).sort((a, b) => a.localeCompare(b));
|
|
907
|
+
return [...ordered, ...remainder];
|
|
908
|
+
}
|
|
909
|
+
|
|
831
910
|
// src/utils/safe-account.ts
|
|
832
911
|
import {
|
|
833
912
|
RHINESTONE_ATTESTER_ADDRESS,
|
|
@@ -1075,7 +1154,7 @@ var signSessionKey = async (config, sessions, allPublicClients, signingParams) =
|
|
|
1075
1154
|
|
|
1076
1155
|
// src/utils/strategy.ts
|
|
1077
1156
|
var PUBLIC_STRATEGIES = `"conservative", "aggressive" or "yieldmaxxing"`;
|
|
1078
|
-
var SUPPORTED_ASSETS = `"
|
|
1157
|
+
var SUPPORTED_ASSETS = Object.entries(ASSET_CONFIGS).filter(([, config]) => config?.enabled === true).map(([symbol]) => `"${symbol}"`).join(", ");
|
|
1079
1158
|
function toInternalStrategy(publicStrategy) {
|
|
1080
1159
|
switch (publicStrategy) {
|
|
1081
1160
|
case "conservative":
|
|
@@ -1155,20 +1234,12 @@ function removeUnusedFields(obj) {
|
|
|
1155
1234
|
return result;
|
|
1156
1235
|
}
|
|
1157
1236
|
function convertAssetInternally(asset) {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
if (asset === "WETH") {
|
|
1162
|
-
return "eth";
|
|
1163
|
-
}
|
|
1164
|
-
if (asset === "EURC") {
|
|
1165
|
-
return "eurc";
|
|
1166
|
-
}
|
|
1167
|
-
if (asset === "NVDAc") {
|
|
1168
|
-
return "nvdac";
|
|
1237
|
+
const assetType = ASSET_CONFIGS[asset]?.assetType;
|
|
1238
|
+
if (assetType === "usdc" || assetType === "eth" || assetType === "eurc" || assetType === "usdt" || assetType === "pyusd" || assetType === "nvdac") {
|
|
1239
|
+
return assetType;
|
|
1169
1240
|
}
|
|
1170
1241
|
throw new Error(
|
|
1171
|
-
`Invalid asset: ${asset}. Must be ${SUPPORTED_ASSETS}.`
|
|
1242
|
+
`Invalid asset: ${asset}. Must be one of: ${SUPPORTED_ASSETS}.`
|
|
1172
1243
|
);
|
|
1173
1244
|
}
|
|
1174
1245
|
function convertStrategiesToPublic(array) {
|
|
@@ -1624,7 +1695,6 @@ var AgentDepositIntentTimeoutError = class extends Error {
|
|
|
1624
1695
|
this.name = "AgentDepositIntentTimeoutError";
|
|
1625
1696
|
}
|
|
1626
1697
|
};
|
|
1627
|
-
var MANAGED_ASSETS = ["USDC", "WETH", "EURC", "NVDAc"];
|
|
1628
1698
|
var _ZyfaiSDK = class _ZyfaiSDK {
|
|
1629
1699
|
/**
|
|
1630
1700
|
* Create an SDK instance bound to a partner API key.
|
|
@@ -1930,7 +2000,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1930
2000
|
async pauseAgent() {
|
|
1931
2001
|
try {
|
|
1932
2002
|
let latest;
|
|
1933
|
-
for (const asset of
|
|
2003
|
+
for (const asset of getManagedAssets()) {
|
|
1934
2004
|
latest = await this.updateUserProfile({ asset, protocols: [] });
|
|
1935
2005
|
}
|
|
1936
2006
|
if (!latest) {
|
|
@@ -1969,7 +2039,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
1969
2039
|
ENDPOINTS.PROTOCOLS()
|
|
1970
2040
|
);
|
|
1971
2041
|
let latest;
|
|
1972
|
-
for (const asset of
|
|
2042
|
+
for (const asset of getManagedAssets()) {
|
|
1973
2043
|
latest = await this.updateUserProtocolsForAsset(
|
|
1974
2044
|
asset,
|
|
1975
2045
|
getAssetChainIds(asset),
|
|
@@ -2748,7 +2818,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2748
2818
|
const allProtocols = await this.httpClient.get(
|
|
2749
2819
|
ENDPOINTS.PROTOCOLS()
|
|
2750
2820
|
);
|
|
2751
|
-
for (const asset of
|
|
2821
|
+
for (const asset of getManagedAssets()) {
|
|
2752
2822
|
try {
|
|
2753
2823
|
await this.updateUserProtocolsForAsset(
|
|
2754
2824
|
asset,
|
|
@@ -2921,6 +2991,77 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
2921
2991
|
);
|
|
2922
2992
|
}
|
|
2923
2993
|
}
|
|
2994
|
+
/**
|
|
2995
|
+
* Apply a strategy and auto-select matching protocols for one or all managed
|
|
2996
|
+
* assets ({@link getManagedAssets}). Prefer this over
|
|
2997
|
+
* {@link updateUserProfile} when changing strategy so protocols stay aligned
|
|
2998
|
+
* with the tier (including `yieldmaxxing` async venues).
|
|
2999
|
+
*
|
|
3000
|
+
* @group Portfolio and execution
|
|
3001
|
+
*/
|
|
3002
|
+
async setStrategyWithProtocols(params) {
|
|
3003
|
+
const { strategy, asset, chains } = params;
|
|
3004
|
+
if (!isValidPublicStrategy(strategy)) {
|
|
3005
|
+
throw new Error(
|
|
3006
|
+
`Invalid strategy: ${strategy}. Must be "conservative", "aggressive" or "yieldmaxxing".`
|
|
3007
|
+
);
|
|
3008
|
+
}
|
|
3009
|
+
const assets = asset ? [asset] : getManagedAssets();
|
|
3010
|
+
if (assets.length === 0) {
|
|
3011
|
+
throw new Error("No managed assets available to configure.");
|
|
3012
|
+
}
|
|
3013
|
+
const plannedUpdates = [];
|
|
3014
|
+
const validationErrors = [];
|
|
3015
|
+
for (const targetAsset of assets) {
|
|
3016
|
+
const supported = getAssetChainIds(targetAsset);
|
|
3017
|
+
if (supported.length === 0) {
|
|
3018
|
+
validationErrors.push(`${targetAsset}: Unsupported asset: ${targetAsset}.`);
|
|
3019
|
+
continue;
|
|
3020
|
+
}
|
|
3021
|
+
const targetChains = chains ?? supported;
|
|
3022
|
+
const unsupported = targetChains.filter((c) => !supported.includes(c));
|
|
3023
|
+
if (unsupported.length > 0) {
|
|
3024
|
+
validationErrors.push(
|
|
3025
|
+
`${targetAsset}: ${targetAsset} is not available on chain ${unsupported.join(
|
|
3026
|
+
", "
|
|
3027
|
+
)}. Supported chains: ${supported.join(", ")}.`
|
|
3028
|
+
);
|
|
3029
|
+
continue;
|
|
3030
|
+
}
|
|
3031
|
+
plannedUpdates.push({ targetAsset, targetChains });
|
|
3032
|
+
}
|
|
3033
|
+
if (validationErrors.length > 0) {
|
|
3034
|
+
throw new Error(
|
|
3035
|
+
`Failed to set strategy with protocols: ${validationErrors.join("; ")}`
|
|
3036
|
+
);
|
|
3037
|
+
}
|
|
3038
|
+
const allProtocols = await this.httpClient.get(
|
|
3039
|
+
ENDPOINTS.PROTOCOLS()
|
|
3040
|
+
);
|
|
3041
|
+
const results = [];
|
|
3042
|
+
const errors = [];
|
|
3043
|
+
for (const { targetAsset, targetChains } of plannedUpdates) {
|
|
3044
|
+
try {
|
|
3045
|
+
const profile = await this.updateUserProtocolsForAsset(
|
|
3046
|
+
targetAsset,
|
|
3047
|
+
targetChains,
|
|
3048
|
+
strategy,
|
|
3049
|
+
allProtocols
|
|
3050
|
+
);
|
|
3051
|
+
results.push(profile);
|
|
3052
|
+
} catch (error) {
|
|
3053
|
+
errors.push(
|
|
3054
|
+
`${targetAsset}: ${error instanceof Error ? error.message : String(error)}`
|
|
3055
|
+
);
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
if (errors.length > 0) {
|
|
3059
|
+
throw new Error(
|
|
3060
|
+
`Failed to set strategy with protocols: ${errors.join("; ")}`
|
|
3061
|
+
);
|
|
3062
|
+
}
|
|
3063
|
+
return results;
|
|
3064
|
+
}
|
|
2924
3065
|
/**
|
|
2925
3066
|
* Drop protocols that have no pools on any of the selected chains for the
|
|
2926
3067
|
* requested asset. The /customization/pools endpoint filters server-side on
|
|
@@ -3051,7 +3192,9 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3051
3192
|
throw new Error("Valid amount is required");
|
|
3052
3193
|
}
|
|
3053
3194
|
if (!asset) {
|
|
3054
|
-
throw new Error(
|
|
3195
|
+
throw new Error(
|
|
3196
|
+
"Asset is required (USDC, WETH, EURC, USDT, PYUSD, or NVDAc)"
|
|
3197
|
+
);
|
|
3055
3198
|
}
|
|
3056
3199
|
if (strategy !== void 0 && !isValidPublicStrategy(strategy)) {
|
|
3057
3200
|
throw new Error(
|
|
@@ -3127,7 +3270,7 @@ var _ZyfaiSDK = class _ZyfaiSDK {
|
|
|
3127
3270
|
}
|
|
3128
3271
|
const txHash = await walletClient.writeContract({
|
|
3129
3272
|
address: token,
|
|
3130
|
-
abi:
|
|
3273
|
+
abi: erc20TransferWriteAbi(assetSymbol),
|
|
3131
3274
|
functionName: "transfer",
|
|
3132
3275
|
args: [safeAddress, amountBigInt],
|
|
3133
3276
|
chain: chainConfig.chain,
|
|
@@ -5874,6 +6017,7 @@ export {
|
|
|
5874
6017
|
getDataApiBaseUrl,
|
|
5875
6018
|
getDefaultTokenAddress,
|
|
5876
6019
|
getExecutionApiBaseUrl,
|
|
6020
|
+
getManagedAssets,
|
|
5877
6021
|
getSupportedChainIds,
|
|
5878
6022
|
getWsUrl,
|
|
5879
6023
|
isSupportedChain
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zyfai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"changeset": "changeset",
|
|
35
35
|
"version-packages": "changeset version",
|
|
36
36
|
"prepublishOnly": "npm run build",
|
|
37
|
+
"prepare": "npm run build",
|
|
37
38
|
"docs": "typedoc",
|
|
38
39
|
"docs:watch": "typedoc --watch",
|
|
39
40
|
"docs:json": "typedoc --json docs/api.json",
|