@owney/sdk 0.6.0-beta.2 → 0.6.1-beta.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 CHANGED
@@ -407,17 +407,6 @@ const usdcBaseApy = await sdk.getAgentApy({
407
407
  console.log(usdcBaseApy.agentApy.zyfai.averageApy); // APY scoped to USDC on Base
408
408
  ```
409
409
 
410
- ### `getAgentAllocation()`
411
-
412
- Get the current fund allocation percentages across agents.
413
-
414
- Returns: `OwneyAgentAllocation`
415
-
416
- ```typescript
417
- const allocation = await sdk.getAgentAllocation();
418
- console.log(allocation.agentAllocation); // { zyfai: 100 }
419
- ```
420
-
421
410
  ## Types
422
411
 
423
412
  ### Configuration
@@ -630,10 +619,6 @@ interface AgentApyDetails {
630
619
  interface OwneyAgentApy {
631
620
  agentApy: Record<AgentId, AgentApy>;
632
621
  }
633
-
634
- interface OwneyAgentAllocation {
635
- agentAllocation: Record<AgentId, number>;
636
- }
637
622
  ```
638
623
 
639
624
  ### Callback Types
package/dist/index.cjs CHANGED
@@ -40,7 +40,7 @@ var P_SUPPORTED_CHAINS = {
40
40
  chainIds: [8453, 42161],
41
41
  chains: ["BASE", "ARBITRUM"]
42
42
  };
43
- var SUPPORTED_TOKENS = ["USDC", "USDT", "WETH"];
43
+ var SUPPORTED_TOKENS = ["USDC", "USDT"];
44
44
  var SUPPORTED_CHAIN_IDS = P_SUPPORTED_CHAINS.chainIds;
45
45
  var SUPPORTED_CHAINS = P_SUPPORTED_CHAINS.chains;
46
46
  var SupportedAssets = [
@@ -61,18 +61,6 @@ var SupportedAssets = [
61
61
  symbol: "USDT",
62
62
  chainId: 42161,
63
63
  decimals: 6
64
- },
65
- {
66
- address: `0x4200000000000000000000000000000000000006`,
67
- symbol: "WETH",
68
- chainId: 8453,
69
- decimals: 18
70
- },
71
- {
72
- address: `0x82aF49447D8a07e3bd95BD0d56f35241523fBab1`,
73
- symbol: "WETH",
74
- chainId: 42161,
75
- decimals: 18
76
64
  }
77
65
  ];
78
66
 
@@ -276,10 +264,15 @@ function mapWeightedApyByChain(raw) {
276
264
  return Object.keys(out).length > 0 ? out : void 0;
277
265
  }
278
266
  function mapApyHistory(raw) {
267
+ const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
268
+ date,
269
+ apy: sumTokenValues(entry.weighted_apy_after_fee)
270
+ })).sort((a, b) => a.date.localeCompare(b.date));
279
271
  return {
280
272
  walletAddress: raw.walletAddress,
281
273
  weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
282
- apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
274
+ apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain),
275
+ history
283
276
  };
284
277
  }
285
278
  function splitOpportunity(opportunity) {
@@ -545,10 +538,6 @@ var DEFAULT_ZYFAI_RPC_URLS = {
545
538
  8453: "https://base-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
546
539
  42161: "https://arb-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V"
547
540
  };
548
- var WETH_ADDRESS_BY_CHAIN = {
549
- 8453: "0x4200000000000000000000000000000000000006",
550
- 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
551
- };
552
541
  var VIEM_CHAIN = { 8453: import_chains.base, 42161: import_chains.arbitrum };
553
542
  var ZyfaiAgent = class {
554
543
  id = "zyfai";
@@ -557,18 +546,12 @@ var ZyfaiAgent = class {
557
546
  {
558
547
  chainId: 8453,
559
548
  chain: "BASE",
560
- assets: [
561
- { symbol: "USDC", minDepositAmount: "1500000" },
562
- { symbol: "WETH", minDepositAmount: "500000000000000" }
563
- ]
549
+ assets: [{ symbol: "USDC", minDepositAmount: "1500000" }]
564
550
  },
565
551
  {
566
552
  chainId: 42161,
567
553
  chain: "ARBITRUM",
568
- assets: [
569
- { symbol: "USDC", minDepositAmount: "1500000" },
570
- { symbol: "WETH", minDepositAmount: "500000000000000" }
571
- ]
554
+ assets: [{ symbol: "USDC", minDepositAmount: "1500000" }]
572
555
  }
573
556
  ];
574
557
  sdk;
@@ -804,7 +787,7 @@ var ZyfaiAgent = class {
804
787
  throw error;
805
788
  }
806
789
  }
807
- async deposit(state, chainId, amount, asset, depositCallback) {
790
+ async deposit(state, chainId, amount, depositCallback) {
808
791
  try {
809
792
  await this.connectFull(state, chainId);
810
793
  const validChainId = isValidChainId(chainId);
@@ -818,15 +801,13 @@ var ZyfaiAgent = class {
818
801
  validChainId,
819
802
  amount
820
803
  );
821
- const tokenAddress = asset === "WETH" ? WETH_ADDRESS_BY_CHAIN[validChainId] : void 0;
822
- await (tokenAddress ? this.sdk.logDeposit(validChainId, txHash, amount, tokenAddress) : this.sdk.logDeposit(validChainId, txHash, amount));
804
+ await this.sdk.logDeposit(validChainId, txHash, amount);
823
805
  return { txHash, smartWallet: wallet.address, amount };
824
806
  }
825
807
  const raw = await this.sdk.depositFunds(
826
808
  this.getAddress(),
827
809
  validChainId,
828
- amount,
829
- asset
810
+ amount
830
811
  );
831
812
  return mapDeposit(raw);
832
813
  } catch (error) {
@@ -1553,7 +1534,7 @@ var OwneySDK = class {
1553
1534
  }
1554
1535
  const state = this.requireState();
1555
1536
  const chainId = this.requireChainId();
1556
- const effectiveCallback = depositCallback ?? (asset === "WETH" ? void 0 : this.getDefaultSponsoredCallback());
1537
+ const effectiveCallback = depositCallback ?? this.getDefaultSponsoredCallback();
1557
1538
  if (agentId) {
1558
1539
  if (this.isAgentDisabled(agentId)) {
1559
1540
  throw new OwneyError(
@@ -1568,13 +1549,7 @@ var OwneySDK = class {
1568
1549
  return withFailureReporting(
1569
1550
  this.apiKey,
1570
1551
  agent.id,
1571
- () => agent.deposit(
1572
- state,
1573
- chainId,
1574
- amount,
1575
- asset,
1576
- effectiveCallback
1577
- )
1552
+ () => agent.deposit(state, chainId, amount, effectiveCallback)
1578
1553
  );
1579
1554
  }
1580
1555
  const totalAmount = BigInt(amount);
@@ -1608,13 +1583,7 @@ var OwneySDK = class {
1608
1583
  agentResults[agent.id] = await withFailureReporting(
1609
1584
  this.apiKey,
1610
1585
  agent.id,
1611
- () => agent.deposit(
1612
- state,
1613
- chainId,
1614
- agentAmount,
1615
- asset,
1616
- effectiveCallback
1617
- )
1586
+ () => agent.deposit(state, chainId, agentAmount, effectiveCallback)
1618
1587
  );
1619
1588
  }
1620
1589
  return { agentResults };
@@ -2144,70 +2113,6 @@ var OwneySDK = class {
2144
2113
  agentApy: results
2145
2114
  };
2146
2115
  }
2147
- /**
2148
- * Get the current fund allocation percentages across agents.
2149
- * @returns Object with agent names as keys and allocation percentages as values
2150
- */
2151
- async getAgentAllocation() {
2152
- const state = this.requireState();
2153
- const chainId = this.requireChainId();
2154
- const activeAgents = this.getActiveAgents();
2155
- const balances = {};
2156
- const positionsByAgent = {};
2157
- let totalBalance = 0;
2158
- const entries = [...activeAgents.entries()];
2159
- const balanceResults = await Promise.allSettled(
2160
- entries.map(async ([id, agent]) => {
2161
- const b = await agent.getBalances(state, chainId);
2162
- return [id, Number(b.totalBalance), b.positions ?? []];
2163
- })
2164
- );
2165
- let successCount = 0;
2166
- const agentErrors = {};
2167
- for (let i = 0; i < balanceResults.length; i++) {
2168
- const settledResult = balanceResults[i];
2169
- const [agentId] = entries[i];
2170
- if (settledResult.status === "fulfilled") {
2171
- const [id, bal, agentPositions] = settledResult.value;
2172
- balances[id] = bal;
2173
- positionsByAgent[id] = agentPositions;
2174
- totalBalance += bal;
2175
- successCount += 1;
2176
- } else {
2177
- const reason = settledResult.reason;
2178
- agentErrors[agentId] = reason instanceof Error ? reason.message : String(reason);
2179
- console.error(`getAgentAllocation agent "${agentId}" failed:`, reason);
2180
- }
2181
- }
2182
- if (successCount === 0) {
2183
- throw new OwneyError(
2184
- "ALLOCATION_ALL_FAILED",
2185
- "Failed to fetch allocation: all agents failed.",
2186
- { agentErrors }
2187
- );
2188
- }
2189
- const allocation = {};
2190
- if (totalBalance === 0) {
2191
- for (const id of activeAgents.keys()) {
2192
- allocation[id] = 0;
2193
- }
2194
- } else {
2195
- for (const id of activeAgents.keys()) {
2196
- allocation[id] = balances[id] > 0 ? Math.max(1, Math.floor(balances[id] / totalBalance * 100)) : 0;
2197
- }
2198
- const remainder = 100 - Object.values(allocation).reduce((a, b) => a + b, 0);
2199
- if (remainder > 0) {
2200
- const largestId = [...activeAgents.keys()].reduce(
2201
- (a, b) => balances[a] >= balances[b] ? a : b
2202
- );
2203
- allocation[largestId] += remainder;
2204
- }
2205
- }
2206
- return {
2207
- agentAllocation: allocation,
2208
- agentPositions: positionsByAgent
2209
- };
2210
- }
2211
2116
  /**
2212
2117
  * Allocation-weighted APY from the current portfolio: each pool's APY
2213
2118
  * weighted by the user's position value in it. More accurate per-user than
package/dist/index.d.cts CHANGED
@@ -14,7 +14,7 @@ interface ConnectionState {
14
14
  walletAddress: `0x${string}`;
15
15
  chainId: number | null;
16
16
  }
17
- declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT", "WETH"];
17
+ declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT"];
18
18
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161];
19
19
  declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM"];
20
20
  type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
@@ -82,11 +82,23 @@ interface OwneyEarnings {
82
82
  agentEarnings: Record<AgentId, AgentEarnings>;
83
83
  }
84
84
  type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
85
+ /** A single day's net APY for the connected account, as a percentage number. */
86
+ interface ApyHistoryPoint {
87
+ /** ISO date string for the day, e.g. "2026-06-20". */
88
+ date: string;
89
+ /** Net (after-fee) weighted APY for that day, summed across tokens. */
90
+ apy: number;
91
+ }
85
92
  interface AccountAgentApy {
86
93
  walletAddress: string;
87
94
  weightedApyAfterFee?: number;
88
95
  weightedApyAfterFeeDetails?: AgentApyDetails;
89
96
  apyByChainAndAsset?: ApyByChainAndAsset;
97
+ /**
98
+ * Daily net-APY series for the requested window (7D/14D/30D), ascending by
99
+ * date. Empty when the provider returns no daily history.
100
+ */
101
+ history?: ApyHistoryPoint[];
90
102
  }
91
103
  interface OwneyAccountApy {
92
104
  totalApy: string;
@@ -171,11 +183,6 @@ interface AgentApy {
171
183
  interface OwneyAgentApy {
172
184
  agentApy: Record<AgentId, AgentApy>;
173
185
  }
174
- interface OwneyAgentAllocation {
175
- agentAllocation: Record<AgentId, number>;
176
- /** Per-agent positions. Empty array for agents that don't expose positions. */
177
- agentPositions: Record<AgentId, OwneyPosition[]>;
178
- }
179
186
 
180
187
  type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
181
188
  interface IAgent {
@@ -184,7 +191,7 @@ interface IAgent {
184
191
  readonly supportedAssets: readonly AgentSupportedAssets[];
185
192
  disconnect(): Promise<void>;
186
193
  activateAgent(state: ConnectionState, chainId: number): Promise<void>;
187
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
194
+ deposit(state: ConnectionState, chainId: number, amount: string, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
188
195
  withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
189
196
  getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
190
197
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
@@ -414,11 +421,6 @@ declare class OwneySDK {
414
421
  * @returns {AgentApy} for a single agent, or {OwneyAgentApy} with per-agent APY
415
422
  */
416
423
  getAgentApy({ agentId, days, tokenSymbol, chainId, }: AgentsApyOptions): Promise<OwneyAgentApy | AgentApy>;
417
- /**
418
- * Get the current fund allocation percentages across agents.
419
- * @returns Object with agent names as keys and allocation percentages as values
420
- */
421
- getAgentAllocation(): Promise<OwneyAgentAllocation>;
422
424
  /**
423
425
  * Allocation-weighted APY from the current portfolio: each pool's APY
424
426
  * weighted by the user's position value in it. More accurate per-user than
@@ -474,4 +476,4 @@ type OwneySIWXConfig = {
474
476
  */
475
477
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
476
478
 
477
- export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
479
+ export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, ApyByChainAndAsset, ApyHistoryPoint, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ interface ConnectionState {
14
14
  walletAddress: `0x${string}`;
15
15
  chainId: number | null;
16
16
  }
17
- declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT", "WETH"];
17
+ declare const SUPPORTED_TOKENS: readonly ["USDC", "USDT"];
18
18
  declare const SUPPORTED_CHAIN_IDS: readonly [8453, 42161];
19
19
  declare const SUPPORTED_CHAINS: readonly ["BASE", "ARBITRUM"];
20
20
  type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
@@ -82,11 +82,23 @@ interface OwneyEarnings {
82
82
  agentEarnings: Record<AgentId, AgentEarnings>;
83
83
  }
84
84
  type ApyByChainAndAsset = Partial<Record<OwneySupportedChainId, Partial<Record<OwneySupportedTokens, number>>>>;
85
+ /** A single day's net APY for the connected account, as a percentage number. */
86
+ interface ApyHistoryPoint {
87
+ /** ISO date string for the day, e.g. "2026-06-20". */
88
+ date: string;
89
+ /** Net (after-fee) weighted APY for that day, summed across tokens. */
90
+ apy: number;
91
+ }
85
92
  interface AccountAgentApy {
86
93
  walletAddress: string;
87
94
  weightedApyAfterFee?: number;
88
95
  weightedApyAfterFeeDetails?: AgentApyDetails;
89
96
  apyByChainAndAsset?: ApyByChainAndAsset;
97
+ /**
98
+ * Daily net-APY series for the requested window (7D/14D/30D), ascending by
99
+ * date. Empty when the provider returns no daily history.
100
+ */
101
+ history?: ApyHistoryPoint[];
90
102
  }
91
103
  interface OwneyAccountApy {
92
104
  totalApy: string;
@@ -171,11 +183,6 @@ interface AgentApy {
171
183
  interface OwneyAgentApy {
172
184
  agentApy: Record<AgentId, AgentApy>;
173
185
  }
174
- interface OwneyAgentAllocation {
175
- agentAllocation: Record<AgentId, number>;
176
- /** Per-agent positions. Empty array for agents that don't expose positions. */
177
- agentPositions: Record<AgentId, OwneyPosition[]>;
178
- }
179
186
 
180
187
  type DepositCallback = (smartWalletAddress: string, chainId: number, amount: string) => Promise<`0x${string}`> | `0x${string}`;
181
188
  interface IAgent {
@@ -184,7 +191,7 @@ interface IAgent {
184
191
  readonly supportedAssets: readonly AgentSupportedAssets[];
185
192
  disconnect(): Promise<void>;
186
193
  activateAgent(state: ConnectionState, chainId: number): Promise<void>;
187
- deposit(state: ConnectionState, chainId: number, amount: string, asset: OwneySupportedTokens, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
194
+ deposit(state: ConnectionState, chainId: number, amount: string, depositCallback?: DepositCallback): Promise<OwneyDepositResult>;
188
195
  withdraw(state: ConnectionState, chainId: number, token: OwneySupportedTokens, amount?: string): Promise<AgentWithdrawResult>;
189
196
  getBalances(state: ConnectionState, chainId: number): Promise<AgentBalance>;
190
197
  getEarnings(state: ConnectionState, chainId: number): Promise<AgentEarnings>;
@@ -414,11 +421,6 @@ declare class OwneySDK {
414
421
  * @returns {AgentApy} for a single agent, or {OwneyAgentApy} with per-agent APY
415
422
  */
416
423
  getAgentApy({ agentId, days, tokenSymbol, chainId, }: AgentsApyOptions): Promise<OwneyAgentApy | AgentApy>;
417
- /**
418
- * Get the current fund allocation percentages across agents.
419
- * @returns Object with agent names as keys and allocation percentages as values
420
- */
421
- getAgentAllocation(): Promise<OwneyAgentAllocation>;
422
424
  /**
423
425
  * Allocation-weighted APY from the current portfolio: each pool's APY
424
426
  * weighted by the user's position value in it. More accurate per-user than
@@ -474,4 +476,4 @@ type OwneySIWXConfig = {
474
476
  */
475
477
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
476
478
 
477
- export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, ApyByChainAndAsset, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentAllocation, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
479
+ export { AccountAgentApy, AccountApyOptions, AgentApy, AgentApyDetails, AgentBalance, AgentChainIncompatibleError, AgentEarnings, AgentHistoryEntry, AgentHistoryPosition, AgentId, AgentNotFoundError, AgentSupportedAsset, AgentSupportedAssets, AgentUserProfile, AgentWithdrawResult, AgentsApyOptions, AllocationAgentApy, ApyByChainAndAsset, ApyHistoryPoint, Asset, ConnectionState, DailyApyDays, DepositCallback, DepositOptions, HistoryAction, HistoryFilters, HistoryOptions, HistoryTransaction, IAgent, InvalidHistoryCursorError, NotConnectedError, OwneyAccountApy, OwneyAgentApy, OwneyAgentHistory, OwneyAllocationApy, OwneyBalances, OwneyDepositResult, OwneyEarnings, OwneyError, OwneyErrorCode, OwneyMultiDepositResult, OwneyPosition, OwneySDK, OwneySDKConfig, OwneySIWXConfig, OwneySupportedChainId, OwneySupportedChains, OwneySupportedTokens, OwneyToken, OwneyUserProfile, OwneyWithdrawResult, RebalanceLog, WithdrawOptions, createOwneySIWX };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var P_SUPPORTED_CHAINS = {
8
8
  chainIds: [8453, 42161],
9
9
  chains: ["BASE", "ARBITRUM"]
10
10
  };
11
- var SUPPORTED_TOKENS = ["USDC", "USDT", "WETH"];
11
+ var SUPPORTED_TOKENS = ["USDC", "USDT"];
12
12
  var SUPPORTED_CHAIN_IDS = P_SUPPORTED_CHAINS.chainIds;
13
13
  var SUPPORTED_CHAINS = P_SUPPORTED_CHAINS.chains;
14
14
  var SupportedAssets = [
@@ -29,18 +29,6 @@ var SupportedAssets = [
29
29
  symbol: "USDT",
30
30
  chainId: 42161,
31
31
  decimals: 6
32
- },
33
- {
34
- address: `0x4200000000000000000000000000000000000006`,
35
- symbol: "WETH",
36
- chainId: 8453,
37
- decimals: 18
38
- },
39
- {
40
- address: `0x82aF49447D8a07e3bd95BD0d56f35241523fBab1`,
41
- symbol: "WETH",
42
- chainId: 42161,
43
- decimals: 18
44
32
  }
45
33
  ];
46
34
 
@@ -244,10 +232,15 @@ function mapWeightedApyByChain(raw) {
244
232
  return Object.keys(out).length > 0 ? out : void 0;
245
233
  }
246
234
  function mapApyHistory(raw) {
235
+ const history = Object.entries(raw.history ?? {}).map(([date, entry]) => ({
236
+ date,
237
+ apy: sumTokenValues(entry.weighted_apy_after_fee)
238
+ })).sort((a, b) => a.date.localeCompare(b.date));
247
239
  return {
248
240
  walletAddress: raw.walletAddress,
249
241
  weightedApyAfterFee: raw.weightedApyAfterFee ? sumTokenValues(raw.weightedApyAfterFee) : void 0,
250
- apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain)
242
+ apyByChainAndAsset: mapWeightedApyByChain(raw.weightedApyAfterFeeByChain),
243
+ history
251
244
  };
252
245
  }
253
246
  function splitOpportunity(opportunity) {
@@ -513,10 +506,6 @@ var DEFAULT_ZYFAI_RPC_URLS = {
513
506
  8453: "https://base-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
514
507
  42161: "https://arb-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V"
515
508
  };
516
- var WETH_ADDRESS_BY_CHAIN = {
517
- 8453: "0x4200000000000000000000000000000000000006",
518
- 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
519
- };
520
509
  var VIEM_CHAIN = { 8453: base, 42161: arbitrum };
521
510
  var ZyfaiAgent = class {
522
511
  id = "zyfai";
@@ -525,18 +514,12 @@ var ZyfaiAgent = class {
525
514
  {
526
515
  chainId: 8453,
527
516
  chain: "BASE",
528
- assets: [
529
- { symbol: "USDC", minDepositAmount: "1500000" },
530
- { symbol: "WETH", minDepositAmount: "500000000000000" }
531
- ]
517
+ assets: [{ symbol: "USDC", minDepositAmount: "1500000" }]
532
518
  },
533
519
  {
534
520
  chainId: 42161,
535
521
  chain: "ARBITRUM",
536
- assets: [
537
- { symbol: "USDC", minDepositAmount: "1500000" },
538
- { symbol: "WETH", minDepositAmount: "500000000000000" }
539
- ]
522
+ assets: [{ symbol: "USDC", minDepositAmount: "1500000" }]
540
523
  }
541
524
  ];
542
525
  sdk;
@@ -772,7 +755,7 @@ var ZyfaiAgent = class {
772
755
  throw error;
773
756
  }
774
757
  }
775
- async deposit(state, chainId, amount, asset, depositCallback) {
758
+ async deposit(state, chainId, amount, depositCallback) {
776
759
  try {
777
760
  await this.connectFull(state, chainId);
778
761
  const validChainId = isValidChainId(chainId);
@@ -786,15 +769,13 @@ var ZyfaiAgent = class {
786
769
  validChainId,
787
770
  amount
788
771
  );
789
- const tokenAddress = asset === "WETH" ? WETH_ADDRESS_BY_CHAIN[validChainId] : void 0;
790
- await (tokenAddress ? this.sdk.logDeposit(validChainId, txHash, amount, tokenAddress) : this.sdk.logDeposit(validChainId, txHash, amount));
772
+ await this.sdk.logDeposit(validChainId, txHash, amount);
791
773
  return { txHash, smartWallet: wallet.address, amount };
792
774
  }
793
775
  const raw = await this.sdk.depositFunds(
794
776
  this.getAddress(),
795
777
  validChainId,
796
- amount,
797
- asset
778
+ amount
798
779
  );
799
780
  return mapDeposit(raw);
800
781
  } catch (error) {
@@ -1525,7 +1506,7 @@ var OwneySDK = class {
1525
1506
  }
1526
1507
  const state = this.requireState();
1527
1508
  const chainId = this.requireChainId();
1528
- const effectiveCallback = depositCallback ?? (asset === "WETH" ? void 0 : this.getDefaultSponsoredCallback());
1509
+ const effectiveCallback = depositCallback ?? this.getDefaultSponsoredCallback();
1529
1510
  if (agentId) {
1530
1511
  if (this.isAgentDisabled(agentId)) {
1531
1512
  throw new OwneyError(
@@ -1540,13 +1521,7 @@ var OwneySDK = class {
1540
1521
  return withFailureReporting(
1541
1522
  this.apiKey,
1542
1523
  agent.id,
1543
- () => agent.deposit(
1544
- state,
1545
- chainId,
1546
- amount,
1547
- asset,
1548
- effectiveCallback
1549
- )
1524
+ () => agent.deposit(state, chainId, amount, effectiveCallback)
1550
1525
  );
1551
1526
  }
1552
1527
  const totalAmount = BigInt(amount);
@@ -1580,13 +1555,7 @@ var OwneySDK = class {
1580
1555
  agentResults[agent.id] = await withFailureReporting(
1581
1556
  this.apiKey,
1582
1557
  agent.id,
1583
- () => agent.deposit(
1584
- state,
1585
- chainId,
1586
- agentAmount,
1587
- asset,
1588
- effectiveCallback
1589
- )
1558
+ () => agent.deposit(state, chainId, agentAmount, effectiveCallback)
1590
1559
  );
1591
1560
  }
1592
1561
  return { agentResults };
@@ -2116,70 +2085,6 @@ var OwneySDK = class {
2116
2085
  agentApy: results
2117
2086
  };
2118
2087
  }
2119
- /**
2120
- * Get the current fund allocation percentages across agents.
2121
- * @returns Object with agent names as keys and allocation percentages as values
2122
- */
2123
- async getAgentAllocation() {
2124
- const state = this.requireState();
2125
- const chainId = this.requireChainId();
2126
- const activeAgents = this.getActiveAgents();
2127
- const balances = {};
2128
- const positionsByAgent = {};
2129
- let totalBalance = 0;
2130
- const entries = [...activeAgents.entries()];
2131
- const balanceResults = await Promise.allSettled(
2132
- entries.map(async ([id, agent]) => {
2133
- const b = await agent.getBalances(state, chainId);
2134
- return [id, Number(b.totalBalance), b.positions ?? []];
2135
- })
2136
- );
2137
- let successCount = 0;
2138
- const agentErrors = {};
2139
- for (let i = 0; i < balanceResults.length; i++) {
2140
- const settledResult = balanceResults[i];
2141
- const [agentId] = entries[i];
2142
- if (settledResult.status === "fulfilled") {
2143
- const [id, bal, agentPositions] = settledResult.value;
2144
- balances[id] = bal;
2145
- positionsByAgent[id] = agentPositions;
2146
- totalBalance += bal;
2147
- successCount += 1;
2148
- } else {
2149
- const reason = settledResult.reason;
2150
- agentErrors[agentId] = reason instanceof Error ? reason.message : String(reason);
2151
- console.error(`getAgentAllocation agent "${agentId}" failed:`, reason);
2152
- }
2153
- }
2154
- if (successCount === 0) {
2155
- throw new OwneyError(
2156
- "ALLOCATION_ALL_FAILED",
2157
- "Failed to fetch allocation: all agents failed.",
2158
- { agentErrors }
2159
- );
2160
- }
2161
- const allocation = {};
2162
- if (totalBalance === 0) {
2163
- for (const id of activeAgents.keys()) {
2164
- allocation[id] = 0;
2165
- }
2166
- } else {
2167
- for (const id of activeAgents.keys()) {
2168
- allocation[id] = balances[id] > 0 ? Math.max(1, Math.floor(balances[id] / totalBalance * 100)) : 0;
2169
- }
2170
- const remainder = 100 - Object.values(allocation).reduce((a, b) => a + b, 0);
2171
- if (remainder > 0) {
2172
- const largestId = [...activeAgents.keys()].reduce(
2173
- (a, b) => balances[a] >= balances[b] ? a : b
2174
- );
2175
- allocation[largestId] += remainder;
2176
- }
2177
- }
2178
- return {
2179
- agentAllocation: allocation,
2180
- agentPositions: positionsByAgent
2181
- };
2182
- }
2183
2088
  /**
2184
2089
  * Allocation-weighted APY from the current portfolio: each pool's APY
2185
2090
  * weighted by the user's position value in it. More accurate per-user than
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.6.0-beta.2",
3
+ "version": "0.6.1-beta.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",