@zyfai/sdk 0.2.9 → 0.2.11

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/dist/index.d.mts CHANGED
@@ -425,6 +425,12 @@ interface BestOpportunityResponse {
425
425
  };
426
426
  enabledChains?: number[];
427
427
  }
428
+ interface RegisterAgentResponse {
429
+ success: boolean;
430
+ txHash: string;
431
+ chainId: number;
432
+ smartWallet: string;
433
+ }
428
434
  interface PolicyData {
429
435
  policy: Address;
430
436
  initData: Hex;
@@ -990,6 +996,51 @@ declare class ZyfaiSDK {
990
996
  * ```
991
997
  */
992
998
  getAggressiveOpportunities(chainId?: number): Promise<OpportunitiesResponse>;
999
+ /**
1000
+ * Get active conservative opportunities (status = "live") with risk and utilization data
1001
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1002
+ *
1003
+ * @param chainId - Optional chain ID filter
1004
+ * @returns Active conservative opportunities with risk data
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
1009
+ * console.log(JSON.stringify(opps, null, 2));
1010
+ * ```
1011
+ */
1012
+ getActiveConservativeOppsRisk(chainId?: number): Promise<any>;
1013
+ /**
1014
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
1015
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1016
+ *
1017
+ * @param chainId - Optional chain ID filter
1018
+ * @returns Active aggressive opportunities with risk data
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
1023
+ * console.log(JSON.stringify(opps, null, 2));
1024
+ * ```
1025
+ */
1026
+ getActiveAggressiveOppsRisk(chainId?: number): Promise<any>;
1027
+ /**
1028
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
1029
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
1030
+ *
1031
+ * @param chainId - Optional chain ID filter
1032
+ * @returns Conservative pools with status data
1033
+ */
1034
+ getConservativePoolStatus(chainId?: number): Promise<any>;
1035
+ /**
1036
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
1037
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
1038
+ *
1039
+ * @param chainId - Optional chain ID filter
1040
+ * @returns Aggressive pools with status data
1041
+ */
1042
+ getAggressivePoolStatus(chainId?: number): Promise<any>;
1043
+ private derivePoolStatus;
993
1044
  /**
994
1045
  * Get daily APY history with weighted average for a wallet
995
1046
  *
@@ -1082,6 +1133,34 @@ declare class ZyfaiSDK {
1082
1133
  * ```
1083
1134
  */
1084
1135
  getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
1136
+ /**
1137
+ * Supported chain IDs for the Identity Registry (ERC-8004)
1138
+ */
1139
+ private static readonly IDENTITY_REGISTRY_CHAIN_IDS;
1140
+ /**
1141
+ * Check if a chain ID supports the Identity Registry
1142
+ */
1143
+ private isSupportedIdentityRegistryChain;
1144
+ /**
1145
+ * Register an agent on the Identity Registry (ERC-8004)
1146
+ *
1147
+ * Fetches a tokenUri from the Zyfai API for the given smart wallet,
1148
+ * then calls `register(tokenUri)` on the Identity Registry contract.
1149
+ *
1150
+ * @param smartWallet - The smart wallet address to register as an agent
1151
+ * @param chainId - Chain ID to register on (only Base 8453 and Arbitrum 42161 supported)
1152
+ * @returns Response with transaction hash and registration details
1153
+ *
1154
+ * @example
1155
+ * ```typescript
1156
+ * const sdk = new ZyfaiSDK({ apiKey: "your-api-key" });
1157
+ * await sdk.connectAccount(privateKey, 8453);
1158
+ *
1159
+ * const result = await sdk.registerAgentOnIdentityRegistry("0xSmartWallet", 8453);
1160
+ * console.log("Tx hash:", result.txHash);
1161
+ * ```
1162
+ */
1163
+ registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
1085
1164
  }
1086
1165
 
1087
- export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
1166
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.d.ts CHANGED
@@ -425,6 +425,12 @@ interface BestOpportunityResponse {
425
425
  };
426
426
  enabledChains?: number[];
427
427
  }
428
+ interface RegisterAgentResponse {
429
+ success: boolean;
430
+ txHash: string;
431
+ chainId: number;
432
+ smartWallet: string;
433
+ }
428
434
  interface PolicyData {
429
435
  policy: Address;
430
436
  initData: Hex;
@@ -990,6 +996,51 @@ declare class ZyfaiSDK {
990
996
  * ```
991
997
  */
992
998
  getAggressiveOpportunities(chainId?: number): Promise<OpportunitiesResponse>;
999
+ /**
1000
+ * Get active conservative opportunities (status = "live") with risk and utilization data
1001
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1002
+ *
1003
+ * @param chainId - Optional chain ID filter
1004
+ * @returns Active conservative opportunities with risk data
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
1009
+ * console.log(JSON.stringify(opps, null, 2));
1010
+ * ```
1011
+ */
1012
+ getActiveConservativeOppsRisk(chainId?: number): Promise<any>;
1013
+ /**
1014
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
1015
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
1016
+ *
1017
+ * @param chainId - Optional chain ID filter
1018
+ * @returns Active aggressive opportunities with risk data
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
1023
+ * console.log(JSON.stringify(opps, null, 2));
1024
+ * ```
1025
+ */
1026
+ getActiveAggressiveOppsRisk(chainId?: number): Promise<any>;
1027
+ /**
1028
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
1029
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
1030
+ *
1031
+ * @param chainId - Optional chain ID filter
1032
+ * @returns Conservative pools with status data
1033
+ */
1034
+ getConservativePoolStatus(chainId?: number): Promise<any>;
1035
+ /**
1036
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
1037
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
1038
+ *
1039
+ * @param chainId - Optional chain ID filter
1040
+ * @returns Aggressive pools with status data
1041
+ */
1042
+ getAggressivePoolStatus(chainId?: number): Promise<any>;
1043
+ private derivePoolStatus;
993
1044
  /**
994
1045
  * Get daily APY history with weighted average for a wallet
995
1046
  *
@@ -1082,6 +1133,34 @@ declare class ZyfaiSDK {
1082
1133
  * ```
1083
1134
  */
1084
1135
  getBestOpportunity(walletAddress: Address, chainId: SupportedChainId): Promise<BestOpportunityResponse>;
1136
+ /**
1137
+ * Supported chain IDs for the Identity Registry (ERC-8004)
1138
+ */
1139
+ private static readonly IDENTITY_REGISTRY_CHAIN_IDS;
1140
+ /**
1141
+ * Check if a chain ID supports the Identity Registry
1142
+ */
1143
+ private isSupportedIdentityRegistryChain;
1144
+ /**
1145
+ * Register an agent on the Identity Registry (ERC-8004)
1146
+ *
1147
+ * Fetches a tokenUri from the Zyfai API for the given smart wallet,
1148
+ * then calls `register(tokenUri)` on the Identity Registry contract.
1149
+ *
1150
+ * @param smartWallet - The smart wallet address to register as an agent
1151
+ * @param chainId - Chain ID to register on (only Base 8453 and Arbitrum 42161 supported)
1152
+ * @returns Response with transaction hash and registration details
1153
+ *
1154
+ * @example
1155
+ * ```typescript
1156
+ * const sdk = new ZyfaiSDK({ apiKey: "your-api-key" });
1157
+ * await sdk.connectAccount(privateKey, 8453);
1158
+ *
1159
+ * const result = await sdk.registerAgentOnIdentityRegistry("0xSmartWallet", 8453);
1160
+ * console.log("Tx hash:", result.txHash);
1161
+ * ```
1162
+ */
1163
+ registerAgentOnIdentityRegistry(smartWallet: string, chainId: SupportedChainId): Promise<RegisterAgentResponse>;
1085
1164
  }
1086
1165
 
1087
- export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
1166
+ export { type APYPerStrategy, type APYPerStrategyResponse, type ActionData, type ActiveWallet, type ActiveWalletsResponse, type AddWalletToSdkResponse, type Address, type BestOpportunityDetails, type BestOpportunityResponse, type ChainConfig, type ChainPortfolio, DEFAULT_TOKEN_ADDRESSES, type DailyApyEntry, type DailyApyHistoryResponse, type DailyEarning, type DailyEarningsResponse, type DebankPortfolioResponse, type DeploySafeResponse, type DepositResponse, type ERC7739Context, type ERC7739Data, type FirstTopupResponse, type Hex, type HistoryEntry, type HistoryPosition, type HistoryResponse, type OnchainEarnings, type OnchainEarningsResponse, type OpportunitiesResponse, type Opportunity, type OpportunityPosition, type PolicyData, type Pool, type PortfolioToken, type Position, type PositionSlot, type PositionsResponse, type Protocol, type ProtocolsResponse, type RebalanceFrequencyResponse, type RegisterAgentResponse, type SDKConfig, type SdkKeyTVLResponse, type Session, type SessionKeyResponse, type SmartWalletByEOAResponse, type SmartWalletResponse, type Strategy, type SupportedChainId, type TVLResponse, type UserDetails, type UserDetailsResponse, type VolumeResponse, type WalletTVL, type WithdrawResponse, ZyfaiSDK, getChainConfig, getDefaultTokenAddress, getSupportedChainIds, isSupportedChain };
package/dist/index.js CHANGED
@@ -76,7 +76,9 @@ var ENDPOINTS = {
76
76
  SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
77
77
  SDK_TVL: "/data/sdk-tvl",
78
78
  // Best Opportunity
79
- BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`
79
+ BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`,
80
+ // Agent Identity Registry
81
+ AGENT_TOKEN_URI: "/users/me/agent-token-uri"
80
82
  };
81
83
  var DATA_ENDPOINTS = {
82
84
  // User Initialization
@@ -288,6 +290,7 @@ var HttpClient = class {
288
290
  };
289
291
 
290
292
  // src/config/abis.ts
293
+ var import_viem = require("viem");
291
294
  var ERC20_ABI = [
292
295
  {
293
296
  name: "transfer",
@@ -355,16 +358,22 @@ var ERC20_ABI = [
355
358
  outputs: [{ name: "", type: "uint256" }]
356
359
  }
357
360
  ];
361
+ var IDENTITY_REGISTRY_ABI = (0, import_viem.parseAbi)([
362
+ "function register() external returns (uint256 agentId)",
363
+ "function register(string tokenUri) external returns (uint256 agentId)",
364
+ "function register(string tokenUri, (string key, bytes value)[] metadata) external returns (uint256 agentId)"
365
+ ]);
366
+ var IDENTITY_REGISTRY_ADDRESS = "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
358
367
 
359
368
  // src/core/ZyfaiSDK.ts
360
369
  var import_accounts2 = require("viem/accounts");
361
- var import_viem4 = require("viem");
370
+ var import_viem5 = require("viem");
362
371
 
363
372
  // src/config/chains.ts
364
- var import_viem = require("viem");
365
- var import_chains = require("viem/chains");
366
373
  var import_viem2 = require("viem");
367
- var plasma = (0, import_viem2.defineChain)({
374
+ var import_chains = require("viem/chains");
375
+ var import_viem3 = require("viem");
376
+ var plasma = (0, import_viem3.defineChain)({
368
377
  id: 9745,
369
378
  name: "Plasma",
370
379
  nativeCurrency: {
@@ -417,9 +426,9 @@ var getChainConfig = (chainId, rpcUrls) => {
417
426
  throw new Error(`Unsupported chain ID: ${chainId}`);
418
427
  }
419
428
  const rpcUrl = rpcUrls && rpcUrls[chainId] || DEFAULT_RPC_URLS[chainId];
420
- const publicClient = (0, import_viem.createPublicClient)({
429
+ const publicClient = (0, import_viem2.createPublicClient)({
421
430
  chain,
422
- transport: (0, import_viem.http)(rpcUrl)
431
+ transport: (0, import_viem2.http)(rpcUrl)
423
432
  });
424
433
  return {
425
434
  chain,
@@ -437,7 +446,7 @@ var getSupportedChainIds = () => {
437
446
  // src/utils/safe-account.ts
438
447
  var import_module_sdk = require("@rhinestone/module-sdk");
439
448
  var import_accounts = require("permissionless/accounts");
440
- var import_viem3 = require("viem");
449
+ var import_viem4 = require("viem");
441
450
  var import_account_abstraction = require("viem/account-abstraction");
442
451
  var SAFE_7579_ADDRESS = "0x7579EE8307284F293B1927136486880611F20002";
443
452
  var ERC7579_LAUNCHPAD_ADDRESS = "0x7579011aB74c46090561ea277Ba79D510c6C00ff";
@@ -447,12 +456,12 @@ var getSafeAccount = async (config) => {
447
456
  if (!safeOwnerAddress) {
448
457
  throw new Error("Safe owner address is required");
449
458
  }
450
- const formattedOwnerAddress = (0, import_viem3.getAddress)(safeOwnerAddress);
459
+ const formattedOwnerAddress = (0, import_viem4.getAddress)(safeOwnerAddress);
451
460
  const ownableValidator = (0, import_module_sdk.getOwnableValidator)({
452
461
  owners: [formattedOwnerAddress],
453
462
  threshold: 1
454
463
  });
455
- const saltHex = (0, import_viem3.fromHex)((0, import_viem3.toHex)(ACCOUNT_SALT), "bigint");
464
+ const saltHex = (0, import_viem4.fromHex)((0, import_viem4.toHex)(ACCOUNT_SALT), "bigint");
456
465
  const tempOwner = {
457
466
  address: formattedOwnerAddress,
458
467
  type: "json-rpc"
@@ -663,7 +672,7 @@ function convertStrategiesToPublic(array) {
663
672
 
664
673
  // src/core/ZyfaiSDK.ts
665
674
  var import_siwe = require("siwe");
666
- var ZyfaiSDK = class {
675
+ var _ZyfaiSDK = class _ZyfaiSDK {
667
676
  constructor(config) {
668
677
  this.signer = null;
669
678
  this.walletClient = null;
@@ -692,7 +701,7 @@ var ZyfaiSDK = class {
692
701
  return;
693
702
  }
694
703
  const walletClient = this.getWalletClient();
695
- const userAddress = (0, import_viem4.getAddress)(walletClient.account.address);
704
+ const userAddress = (0, import_viem5.getAddress)(walletClient.account.address);
696
705
  const chainId = this.currentChainId || walletClient.chain?.id || 8453;
697
706
  const challengeResponse = await this.httpClient.post(ENDPOINTS.AUTH_CHALLENGE, {});
698
707
  let uri;
@@ -971,10 +980,10 @@ var ZyfaiSDK = class {
971
980
  this.walletClient.chain?.id || 8453,
972
981
  this.rpcUrls
973
982
  );
974
- this.walletClient = (0, import_viem4.createWalletClient)({
983
+ this.walletClient = (0, import_viem5.createWalletClient)({
975
984
  account: newAddress,
976
985
  chain: chainConfig.chain,
977
- transport: (0, import_viem4.custom)(this.currentProvider)
986
+ transport: (0, import_viem5.custom)(this.currentProvider)
978
987
  });
979
988
  this.currentChainId = this.walletClient.chain?.id || null;
980
989
  try {
@@ -1026,10 +1035,10 @@ var ZyfaiSDK = class {
1026
1035
  }
1027
1036
  this.signer = (0, import_accounts2.privateKeyToAccount)(privateKey);
1028
1037
  this.currentChainId = chainId;
1029
- this.walletClient = (0, import_viem4.createWalletClient)({
1038
+ this.walletClient = (0, import_viem5.createWalletClient)({
1030
1039
  account: this.signer,
1031
1040
  chain: chainConfig.chain,
1032
- transport: (0, import_viem4.http)(chainConfig.rpcUrl)
1041
+ transport: (0, import_viem5.http)(chainConfig.rpcUrl)
1033
1042
  });
1034
1043
  connectedAddress = this.signer.address;
1035
1044
  this.currentProvider = null;
@@ -1047,10 +1056,10 @@ var ZyfaiSDK = class {
1047
1056
  if (!accounts || accounts.length === 0) {
1048
1057
  throw new Error("No accounts found in wallet provider");
1049
1058
  }
1050
- this.walletClient = (0, import_viem4.createWalletClient)({
1059
+ this.walletClient = (0, import_viem5.createWalletClient)({
1051
1060
  account: accounts[0],
1052
1061
  chain: chainConfig.chain,
1053
- transport: (0, import_viem4.custom)(provider)
1062
+ transport: (0, import_viem5.custom)(provider)
1054
1063
  });
1055
1064
  connectedAddress = accounts[0];
1056
1065
  this.currentProvider = provider;
@@ -1059,7 +1068,7 @@ var ZyfaiSDK = class {
1059
1068
  provider.on("accountsChanged", this.handleAccountsChanged.bind(this));
1060
1069
  }
1061
1070
  } else if (provider.account && provider.transport) {
1062
- this.walletClient = (0, import_viem4.createWalletClient)({
1071
+ this.walletClient = (0, import_viem5.createWalletClient)({
1063
1072
  account: provider.account,
1064
1073
  chain: chainConfig.chain,
1065
1074
  transport: provider.transport
@@ -1112,10 +1121,10 @@ var ZyfaiSDK = class {
1112
1121
  targetChainId,
1113
1122
  this.rpcUrls
1114
1123
  );
1115
- return (0, import_viem4.createWalletClient)({
1124
+ return (0, import_viem5.createWalletClient)({
1116
1125
  account: this.signer,
1117
1126
  chain: targetChainConfig.chain,
1118
- transport: (0, import_viem4.http)(targetChainConfig.rpcUrl)
1127
+ transport: (0, import_viem5.http)(targetChainConfig.rpcUrl)
1119
1128
  });
1120
1129
  } else {
1121
1130
  if (!this.walletClient) {
@@ -2240,6 +2249,156 @@ var ZyfaiSDK = class {
2240
2249
  );
2241
2250
  }
2242
2251
  }
2252
+ /**
2253
+ * Get active conservative opportunities (status = "live") with risk and utilization data
2254
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2255
+ *
2256
+ * @param chainId - Optional chain ID filter
2257
+ * @returns Active conservative opportunities with risk data
2258
+ *
2259
+ * @example
2260
+ * ```typescript
2261
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
2262
+ * console.log(JSON.stringify(opps, null, 2));
2263
+ * ```
2264
+ */
2265
+ async getActiveConservativeOppsRisk(chainId) {
2266
+ try {
2267
+ const response = await this.httpClient.dataGet(
2268
+ DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId)
2269
+ );
2270
+ const data = response.data || response || [];
2271
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2272
+ const tvl = o.tvl || 0;
2273
+ const liquidity = o.liquidity || 0;
2274
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2275
+ return {
2276
+ poolName: o.pool_name,
2277
+ protocolName: o.protocol_name,
2278
+ chainId: o.chain_id,
2279
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2280
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2281
+ tvlStability: o.isTvlStable ?? null,
2282
+ apyStability: o.isApyStable30Days ?? null,
2283
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2284
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2285
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2286
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2287
+ collateralSymbols: o.collateral_symbols || []
2288
+ };
2289
+ }) : [];
2290
+ return active;
2291
+ } catch (error) {
2292
+ throw new Error(
2293
+ `Failed to get active conservative opportunities risk: ${error.message}`
2294
+ );
2295
+ }
2296
+ }
2297
+ /**
2298
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
2299
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2300
+ *
2301
+ * @param chainId - Optional chain ID filter
2302
+ * @returns Active aggressive opportunities with risk data
2303
+ *
2304
+ * @example
2305
+ * ```typescript
2306
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
2307
+ * console.log(JSON.stringify(opps, null, 2));
2308
+ * ```
2309
+ */
2310
+ async getActiveAggressiveOppsRisk(chainId) {
2311
+ try {
2312
+ const response = await this.httpClient.dataGet(
2313
+ DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId)
2314
+ );
2315
+ const data = response.data || response || [];
2316
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2317
+ const tvl = o.tvl || 0;
2318
+ const liquidity = o.liquidity || 0;
2319
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2320
+ return {
2321
+ poolName: o.pool_name,
2322
+ protocolName: o.protocol_name,
2323
+ chainId: o.chain_id,
2324
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2325
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2326
+ tvlStability: o.isTvlStable ?? null,
2327
+ apyStability: o.isApyStable30Days ?? null,
2328
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2329
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2330
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2331
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2332
+ collateralSymbols: o.collateral_symbols || []
2333
+ };
2334
+ }) : [];
2335
+ return active;
2336
+ } catch (error) {
2337
+ throw new Error(
2338
+ `Failed to get active aggressive opportunities risk: ${error.message}`
2339
+ );
2340
+ }
2341
+ }
2342
+ /**
2343
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
2344
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
2345
+ *
2346
+ * @param chainId - Optional chain ID filter
2347
+ * @returns Conservative pools with status data
2348
+ */
2349
+ async getConservativePoolStatus(chainId) {
2350
+ const pools = await this.getActiveConservativeOppsRisk(chainId);
2351
+ return pools.map((p) => this.derivePoolStatus(p));
2352
+ }
2353
+ /**
2354
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
2355
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
2356
+ *
2357
+ * @param chainId - Optional chain ID filter
2358
+ * @returns Aggressive pools with status data
2359
+ */
2360
+ async getAggressivePoolStatus(chainId) {
2361
+ const pools = await this.getActiveAggressiveOppsRisk(chainId);
2362
+ return pools.map((p) => this.derivePoolStatus(p));
2363
+ }
2364
+ derivePoolStatus(p) {
2365
+ let riskSignals = 0;
2366
+ if (p.tvlStability === false) riskSignals++;
2367
+ if (p.apyStability === false) riskSignals++;
2368
+ if (p.tvlApyCombinedRisk === false) riskSignals++;
2369
+ if (p.liquidityDepth === "shallow") riskSignals++;
2370
+ if (p.utilizationRate > 90) riskSignals++;
2371
+ const riskLevel = riskSignals >= 3 ? "high" : riskSignals >= 1 ? "medium" : "low";
2372
+ const stabilityScore = (p.tvlStability === true ? 1 : 0) + (p.apyStability === true ? 1 : 0) + (p.tvlApyCombinedRisk === true ? 1 : 0);
2373
+ const liquidityBonus = p.liquidityDepth === "deep" ? 1 : p.liquidityDepth === "moderate" ? 0.5 : 0;
2374
+ const healthTotal = stabilityScore + liquidityBonus;
2375
+ const healthScore = healthTotal >= 3 ? "healthy" : healthTotal >= 1.5 ? "moderate" : "risky";
2376
+ const apy7d = p.avgCombinedApy7d;
2377
+ const apy30d = p.avgCombinedApy30d;
2378
+ let apyTrend = "stable";
2379
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2380
+ const change = (apy7d - apy30d) / apy30d;
2381
+ if (change > 0.1) apyTrend = "rising";
2382
+ else if (change < -0.1) apyTrend = "falling";
2383
+ }
2384
+ let yieldConsistency = "consistent";
2385
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2386
+ const spread = Math.abs(apy7d - apy30d) / apy30d;
2387
+ if (spread > 0.3) yieldConsistency = "volatile";
2388
+ else if (spread > 0.1) yieldConsistency = "mixed";
2389
+ }
2390
+ return {
2391
+ poolName: p.poolName,
2392
+ protocolName: p.protocolName,
2393
+ chainId: p.chainId,
2394
+ healthScore,
2395
+ riskLevel,
2396
+ apyTrend,
2397
+ yieldConsistency,
2398
+ liquidityDepth: p.liquidityDepth,
2399
+ avgCombinedApy7d: p.avgCombinedApy7d
2400
+ };
2401
+ }
2243
2402
  // ============================================================================
2244
2403
  // APY History Methods (Data API v2)
2245
2404
  // ============================================================================
@@ -2424,7 +2583,88 @@ var ZyfaiSDK = class {
2424
2583
  );
2425
2584
  }
2426
2585
  }
2586
+ /**
2587
+ * Check if a chain ID supports the Identity Registry
2588
+ */
2589
+ isSupportedIdentityRegistryChain(chainId) {
2590
+ return _ZyfaiSDK.IDENTITY_REGISTRY_CHAIN_IDS.includes(chainId);
2591
+ }
2592
+ /**
2593
+ * Register an agent on the Identity Registry (ERC-8004)
2594
+ *
2595
+ * Fetches a tokenUri from the Zyfai API for the given smart wallet,
2596
+ * then calls `register(tokenUri)` on the Identity Registry contract.
2597
+ *
2598
+ * @param smartWallet - The smart wallet address to register as an agent
2599
+ * @param chainId - Chain ID to register on (only Base 8453 and Arbitrum 42161 supported)
2600
+ * @returns Response with transaction hash and registration details
2601
+ *
2602
+ * @example
2603
+ * ```typescript
2604
+ * const sdk = new ZyfaiSDK({ apiKey: "your-api-key" });
2605
+ * await sdk.connectAccount(privateKey, 8453);
2606
+ *
2607
+ * const result = await sdk.registerAgentOnIdentityRegistry("0xSmartWallet", 8453);
2608
+ * console.log("Tx hash:", result.txHash);
2609
+ * ```
2610
+ */
2611
+ async registerAgentOnIdentityRegistry(smartWallet, chainId) {
2612
+ if (!smartWallet) {
2613
+ throw new Error("Smart wallet address is required");
2614
+ }
2615
+ if (!this.isSupportedIdentityRegistryChain(chainId)) {
2616
+ throw new Error(
2617
+ `Chain ${chainId} is not supported for Identity Registry. Supported chains: Base (8453), Arbitrum (42161)`
2618
+ );
2619
+ }
2620
+ try {
2621
+ const tokenUriResponse = await this.httpClient.post(
2622
+ ENDPOINTS.AGENT_TOKEN_URI,
2623
+ { smartWallet }
2624
+ );
2625
+ if (!tokenUriResponse.tokenUri) {
2626
+ throw new Error("API did not return a tokenUri");
2627
+ }
2628
+ const callData = (0, import_viem5.encodeFunctionData)({
2629
+ abi: IDENTITY_REGISTRY_ABI,
2630
+ functionName: "register",
2631
+ args: [tokenUriResponse.tokenUri]
2632
+ });
2633
+ const walletClient = this.getWalletClient(chainId);
2634
+ const chainConfig = getChainConfig(chainId, this.rpcUrls);
2635
+ const txHash = await walletClient.sendTransaction({
2636
+ to: IDENTITY_REGISTRY_ADDRESS,
2637
+ data: callData,
2638
+ chain: chainConfig.chain,
2639
+ account: walletClient.account
2640
+ });
2641
+ const receipt = await chainConfig.publicClient.waitForTransactionReceipt({
2642
+ hash: txHash
2643
+ });
2644
+ if (receipt.status !== "success") {
2645
+ throw new Error("Identity Registry registration transaction failed");
2646
+ }
2647
+ return {
2648
+ success: true,
2649
+ txHash,
2650
+ chainId,
2651
+ smartWallet
2652
+ };
2653
+ } catch (error) {
2654
+ throw new Error(
2655
+ `Failed to register agent on Identity Registry: ${error.message}`
2656
+ );
2657
+ }
2658
+ }
2427
2659
  };
2660
+ // ============================================================================
2661
+ // Agent Identity Registry
2662
+ // ============================================================================
2663
+ /**
2664
+ * Supported chain IDs for the Identity Registry (ERC-8004)
2665
+ */
2666
+ _ZyfaiSDK.IDENTITY_REGISTRY_CHAIN_IDS = [8453, 42161];
2667
+ var ZyfaiSDK = _ZyfaiSDK;
2428
2668
  // Annotate the CommonJS export names for ESM import in node:
2429
2669
  0 && (module.exports = {
2430
2670
  DEFAULT_TOKEN_ADDRESSES,
package/dist/index.mjs CHANGED
@@ -35,7 +35,9 @@ var ENDPOINTS = {
35
35
  SDK_ALLOWED_WALLETS: "/data/sdk-allowed-wallets",
36
36
  SDK_TVL: "/data/sdk-tvl",
37
37
  // Best Opportunity
38
- BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`
38
+ BEST_OPPORTUNITY: (walletAddress, chainId) => `/data/best-opportunity?walletAddress=${walletAddress}&chainId=${chainId}`,
39
+ // Agent Identity Registry
40
+ AGENT_TOKEN_URI: "/users/me/agent-token-uri"
39
41
  };
40
42
  var DATA_ENDPOINTS = {
41
43
  // User Initialization
@@ -247,6 +249,7 @@ var HttpClient = class {
247
249
  };
248
250
 
249
251
  // src/config/abis.ts
252
+ import { parseAbi } from "viem";
250
253
  var ERC20_ABI = [
251
254
  {
252
255
  name: "transfer",
@@ -314,6 +317,12 @@ var ERC20_ABI = [
314
317
  outputs: [{ name: "", type: "uint256" }]
315
318
  }
316
319
  ];
320
+ var IDENTITY_REGISTRY_ABI = parseAbi([
321
+ "function register() external returns (uint256 agentId)",
322
+ "function register(string tokenUri) external returns (uint256 agentId)",
323
+ "function register(string tokenUri, (string key, bytes value)[] metadata) external returns (uint256 agentId)"
324
+ ]);
325
+ var IDENTITY_REGISTRY_ADDRESS = "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
317
326
 
318
327
  // src/core/ZyfaiSDK.ts
319
328
  import { privateKeyToAccount } from "viem/accounts";
@@ -321,7 +330,8 @@ import {
321
330
  createWalletClient,
322
331
  custom,
323
332
  http as http2,
324
- getAddress as getAddress2
333
+ getAddress as getAddress2,
334
+ encodeFunctionData
325
335
  } from "viem";
326
336
 
327
337
  // src/config/chains.ts
@@ -640,7 +650,7 @@ function convertStrategiesToPublic(array) {
640
650
 
641
651
  // src/core/ZyfaiSDK.ts
642
652
  import { SiweMessage } from "siwe";
643
- var ZyfaiSDK = class {
653
+ var _ZyfaiSDK = class _ZyfaiSDK {
644
654
  constructor(config) {
645
655
  this.signer = null;
646
656
  this.walletClient = null;
@@ -2217,6 +2227,156 @@ var ZyfaiSDK = class {
2217
2227
  );
2218
2228
  }
2219
2229
  }
2230
+ /**
2231
+ * Get active conservative opportunities (status = "live") with risk and utilization data
2232
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2233
+ *
2234
+ * @param chainId - Optional chain ID filter
2235
+ * @returns Active conservative opportunities with risk data
2236
+ *
2237
+ * @example
2238
+ * ```typescript
2239
+ * const opps = await sdk.getActiveConservativeOppsRisk(8453);
2240
+ * console.log(JSON.stringify(opps, null, 2));
2241
+ * ```
2242
+ */
2243
+ async getActiveConservativeOppsRisk(chainId) {
2244
+ try {
2245
+ const response = await this.httpClient.dataGet(
2246
+ DATA_ENDPOINTS.OPPORTUNITIES_SAFE(chainId)
2247
+ );
2248
+ const data = response.data || response || [];
2249
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2250
+ const tvl = o.tvl || 0;
2251
+ const liquidity = o.liquidity || 0;
2252
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2253
+ return {
2254
+ poolName: o.pool_name,
2255
+ protocolName: o.protocol_name,
2256
+ chainId: o.chain_id,
2257
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2258
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2259
+ tvlStability: o.isTvlStable ?? null,
2260
+ apyStability: o.isApyStable30Days ?? null,
2261
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2262
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2263
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2264
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2265
+ collateralSymbols: o.collateral_symbols || []
2266
+ };
2267
+ }) : [];
2268
+ return active;
2269
+ } catch (error) {
2270
+ throw new Error(
2271
+ `Failed to get active conservative opportunities risk: ${error.message}`
2272
+ );
2273
+ }
2274
+ }
2275
+ /**
2276
+ * Get active aggressive opportunities (status = "live") with risk and utilization data
2277
+ * Returns pool info, liquidity depth (true if > 1M), utilization rate, stability metrics, avg APY, and collateral
2278
+ *
2279
+ * @param chainId - Optional chain ID filter
2280
+ * @returns Active aggressive opportunities with risk data
2281
+ *
2282
+ * @example
2283
+ * ```typescript
2284
+ * const opps = await sdk.getActiveAggressiveOppsRisk(8453);
2285
+ * console.log(JSON.stringify(opps, null, 2));
2286
+ * ```
2287
+ */
2288
+ async getActiveAggressiveOppsRisk(chainId) {
2289
+ try {
2290
+ const response = await this.httpClient.dataGet(
2291
+ DATA_ENDPOINTS.OPPORTUNITIES_DEGEN(chainId)
2292
+ );
2293
+ const data = response.data || response || [];
2294
+ const active = Array.isArray(data) ? data.filter((o) => o.status === "live").map((o) => {
2295
+ const tvl = o.tvl || 0;
2296
+ const liquidity = o.liquidity || 0;
2297
+ const utilizationRate = tvl > 0 ? (tvl - liquidity) / tvl : 0;
2298
+ return {
2299
+ poolName: o.pool_name,
2300
+ protocolName: o.protocol_name,
2301
+ chainId: o.chain_id,
2302
+ liquidityDepth: liquidity > 1e7 ? "deep" : liquidity > 1e6 ? "moderate" : "shallow",
2303
+ utilizationRate: Math.round(utilizationRate * 1e4) / 100,
2304
+ tvlStability: o.isTvlStable ?? null,
2305
+ apyStability: o.isApyStable30Days ?? null,
2306
+ tvlApyCombinedRisk: o.isApyTvlStable ?? null,
2307
+ avgCombinedApy7d: o.averageCombinedApy7Days ?? null,
2308
+ avgCombinedApy15d: o.averageCombinedApy15Days ?? null,
2309
+ avgCombinedApy30d: o.averageCombinedApy30Days ?? null,
2310
+ collateralSymbols: o.collateral_symbols || []
2311
+ };
2312
+ }) : [];
2313
+ return active;
2314
+ } catch (error) {
2315
+ throw new Error(
2316
+ `Failed to get active aggressive opportunities risk: ${error.message}`
2317
+ );
2318
+ }
2319
+ }
2320
+ /**
2321
+ * Get conservative pool status with derived health, risk, APY trend, and yield consistency
2322
+ * Builds on getActiveConservativeOppsRisk and computes higher-level status indicators
2323
+ *
2324
+ * @param chainId - Optional chain ID filter
2325
+ * @returns Conservative pools with status data
2326
+ */
2327
+ async getConservativePoolStatus(chainId) {
2328
+ const pools = await this.getActiveConservativeOppsRisk(chainId);
2329
+ return pools.map((p) => this.derivePoolStatus(p));
2330
+ }
2331
+ /**
2332
+ * Get aggressive pool status with derived health, risk, APY trend, and yield consistency
2333
+ * Builds on getActiveAggressiveOppsRisk and computes higher-level status indicators
2334
+ *
2335
+ * @param chainId - Optional chain ID filter
2336
+ * @returns Aggressive pools with status data
2337
+ */
2338
+ async getAggressivePoolStatus(chainId) {
2339
+ const pools = await this.getActiveAggressiveOppsRisk(chainId);
2340
+ return pools.map((p) => this.derivePoolStatus(p));
2341
+ }
2342
+ derivePoolStatus(p) {
2343
+ let riskSignals = 0;
2344
+ if (p.tvlStability === false) riskSignals++;
2345
+ if (p.apyStability === false) riskSignals++;
2346
+ if (p.tvlApyCombinedRisk === false) riskSignals++;
2347
+ if (p.liquidityDepth === "shallow") riskSignals++;
2348
+ if (p.utilizationRate > 90) riskSignals++;
2349
+ const riskLevel = riskSignals >= 3 ? "high" : riskSignals >= 1 ? "medium" : "low";
2350
+ const stabilityScore = (p.tvlStability === true ? 1 : 0) + (p.apyStability === true ? 1 : 0) + (p.tvlApyCombinedRisk === true ? 1 : 0);
2351
+ const liquidityBonus = p.liquidityDepth === "deep" ? 1 : p.liquidityDepth === "moderate" ? 0.5 : 0;
2352
+ const healthTotal = stabilityScore + liquidityBonus;
2353
+ const healthScore = healthTotal >= 3 ? "healthy" : healthTotal >= 1.5 ? "moderate" : "risky";
2354
+ const apy7d = p.avgCombinedApy7d;
2355
+ const apy30d = p.avgCombinedApy30d;
2356
+ let apyTrend = "stable";
2357
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2358
+ const change = (apy7d - apy30d) / apy30d;
2359
+ if (change > 0.1) apyTrend = "rising";
2360
+ else if (change < -0.1) apyTrend = "falling";
2361
+ }
2362
+ let yieldConsistency = "consistent";
2363
+ if (apy7d != null && apy30d != null && apy30d !== 0) {
2364
+ const spread = Math.abs(apy7d - apy30d) / apy30d;
2365
+ if (spread > 0.3) yieldConsistency = "volatile";
2366
+ else if (spread > 0.1) yieldConsistency = "mixed";
2367
+ }
2368
+ return {
2369
+ poolName: p.poolName,
2370
+ protocolName: p.protocolName,
2371
+ chainId: p.chainId,
2372
+ healthScore,
2373
+ riskLevel,
2374
+ apyTrend,
2375
+ yieldConsistency,
2376
+ liquidityDepth: p.liquidityDepth,
2377
+ avgCombinedApy7d: p.avgCombinedApy7d
2378
+ };
2379
+ }
2220
2380
  // ============================================================================
2221
2381
  // APY History Methods (Data API v2)
2222
2382
  // ============================================================================
@@ -2401,7 +2561,88 @@ var ZyfaiSDK = class {
2401
2561
  );
2402
2562
  }
2403
2563
  }
2564
+ /**
2565
+ * Check if a chain ID supports the Identity Registry
2566
+ */
2567
+ isSupportedIdentityRegistryChain(chainId) {
2568
+ return _ZyfaiSDK.IDENTITY_REGISTRY_CHAIN_IDS.includes(chainId);
2569
+ }
2570
+ /**
2571
+ * Register an agent on the Identity Registry (ERC-8004)
2572
+ *
2573
+ * Fetches a tokenUri from the Zyfai API for the given smart wallet,
2574
+ * then calls `register(tokenUri)` on the Identity Registry contract.
2575
+ *
2576
+ * @param smartWallet - The smart wallet address to register as an agent
2577
+ * @param chainId - Chain ID to register on (only Base 8453 and Arbitrum 42161 supported)
2578
+ * @returns Response with transaction hash and registration details
2579
+ *
2580
+ * @example
2581
+ * ```typescript
2582
+ * const sdk = new ZyfaiSDK({ apiKey: "your-api-key" });
2583
+ * await sdk.connectAccount(privateKey, 8453);
2584
+ *
2585
+ * const result = await sdk.registerAgentOnIdentityRegistry("0xSmartWallet", 8453);
2586
+ * console.log("Tx hash:", result.txHash);
2587
+ * ```
2588
+ */
2589
+ async registerAgentOnIdentityRegistry(smartWallet, chainId) {
2590
+ if (!smartWallet) {
2591
+ throw new Error("Smart wallet address is required");
2592
+ }
2593
+ if (!this.isSupportedIdentityRegistryChain(chainId)) {
2594
+ throw new Error(
2595
+ `Chain ${chainId} is not supported for Identity Registry. Supported chains: Base (8453), Arbitrum (42161)`
2596
+ );
2597
+ }
2598
+ try {
2599
+ const tokenUriResponse = await this.httpClient.post(
2600
+ ENDPOINTS.AGENT_TOKEN_URI,
2601
+ { smartWallet }
2602
+ );
2603
+ if (!tokenUriResponse.tokenUri) {
2604
+ throw new Error("API did not return a tokenUri");
2605
+ }
2606
+ const callData = encodeFunctionData({
2607
+ abi: IDENTITY_REGISTRY_ABI,
2608
+ functionName: "register",
2609
+ args: [tokenUriResponse.tokenUri]
2610
+ });
2611
+ const walletClient = this.getWalletClient(chainId);
2612
+ const chainConfig = getChainConfig(chainId, this.rpcUrls);
2613
+ const txHash = await walletClient.sendTransaction({
2614
+ to: IDENTITY_REGISTRY_ADDRESS,
2615
+ data: callData,
2616
+ chain: chainConfig.chain,
2617
+ account: walletClient.account
2618
+ });
2619
+ const receipt = await chainConfig.publicClient.waitForTransactionReceipt({
2620
+ hash: txHash
2621
+ });
2622
+ if (receipt.status !== "success") {
2623
+ throw new Error("Identity Registry registration transaction failed");
2624
+ }
2625
+ return {
2626
+ success: true,
2627
+ txHash,
2628
+ chainId,
2629
+ smartWallet
2630
+ };
2631
+ } catch (error) {
2632
+ throw new Error(
2633
+ `Failed to register agent on Identity Registry: ${error.message}`
2634
+ );
2635
+ }
2636
+ }
2404
2637
  };
2638
+ // ============================================================================
2639
+ // Agent Identity Registry
2640
+ // ============================================================================
2641
+ /**
2642
+ * Supported chain IDs for the Identity Registry (ERC-8004)
2643
+ */
2644
+ _ZyfaiSDK.IDENTITY_REGISTRY_CHAIN_IDS = [8453, 42161];
2645
+ var ZyfaiSDK = _ZyfaiSDK;
2405
2646
  export {
2406
2647
  DEFAULT_TOKEN_ADDRESSES,
2407
2648
  ZyfaiSDK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyfai/sdk",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "TypeScript SDK for Zyfai Yield Optimization Engine - Deploy Safe smart wallets, manage session keys, and interact with DeFi protocols",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",