@owney/sdk 0.2.12 → 0.2.13

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
@@ -244,11 +244,17 @@ Returns: `AgentEarnings` (single agent) or `OwneyEarnings` (all agents)
244
244
  const earnings = await sdk.getEarnings("zyfai");
245
245
  console.log(earnings.smartWallet); // "0x..."
246
246
  console.log(earnings.lifetimeEarnings); // 42.5
247
+ console.log(earnings.tokens);
248
+ // [
249
+ // { chain: "BASE", chainId: 8453, asset: "USDC", amount: "30.0" },
250
+ // { chain: "ARBITRUM", chainId: 42161, asset: "USDC", amount: "12.5" },
251
+ // ]
247
252
 
248
253
  // All agents
249
254
  const allEarnings = await sdk.getEarnings();
250
255
  console.log(allEarnings.totalEarnings); // "85.0"
251
256
  console.log(allEarnings.agentEarnings.zyfai.lifetimeEarnings); // 42.5
257
+ console.log(allEarnings.agentEarnings.zyfai.tokens); // per-chain, per-asset breakdown
252
258
  ```
253
259
 
254
260
  ### `getAccountApy({ agentId?, days })`
@@ -535,6 +541,7 @@ interface OwneyBalances {
535
541
  interface AgentEarnings {
536
542
  smartWallet: `0x${string}`;
537
543
  lifetimeEarnings: number;
544
+ tokens: OwneyToken[];
538
545
  }
539
546
 
540
547
  interface OwneyEarnings {
@@ -718,7 +725,3 @@ The three convenience subclasses extend `OwneyError` and remain backwards-compat
718
725
  | `NotConnectedError` | `NOT_CONNECTED` | — |
719
726
  | `AgentNotFoundError` | `AGENT_NOT_FOUND` | — |
720
727
  | `AgentChainIncompatibleError` | `AGENT_CHAIN_INCOMPATIBLE` | `incompatibleAgents`, `connectedChainId` |
721
-
722
- ## License
723
-
724
- MIT
package/dist/index.cjs CHANGED
@@ -186,9 +186,26 @@ function sumTokenEarnings(tokens) {
186
186
  return Object.values(tokens).reduce((sum, val) => sum + Number(val), 0);
187
187
  }
188
188
  function mapEarnings(raw, smartWallet) {
189
+ const totalEarningsByChain = raw.data.totalEarningsByChain;
190
+ const tokens = [];
191
+ for (const [chainIdKey, tokensBySymbol] of Object.entries(
192
+ totalEarningsByChain
193
+ )) {
194
+ const positionChainId = Number(chainIdKey);
195
+ for (const [symbol, earnings] of Object.entries(tokensBySymbol ?? {})) {
196
+ const amount = Number(earnings);
197
+ tokens.push({
198
+ chain: CHAIN_ID_TO_NAME[positionChainId] ?? "BASE",
199
+ chainId: positionChainId,
200
+ asset: symbol,
201
+ amount: String(amount)
202
+ });
203
+ }
204
+ }
189
205
  return {
190
206
  smartWallet,
191
- lifetimeEarnings: sumTokenEarnings(raw.data.totalEarningsByToken)
207
+ lifetimeEarnings: sumTokenEarnings(raw.data.totalEarningsByToken),
208
+ tokens
192
209
  };
193
210
  }
194
211
  function mapApyHistory(raw) {
@@ -776,7 +793,7 @@ var OwneySDK = class {
776
793
  }
777
794
  /**
778
795
  * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
779
- * Validates that the asset is supported and amount meets minimums for the target agent(s).
796
+ * Validates that the asset is supported and amount meets minimums for the target agent(s).
780
797
  * @param options - Deposit parameters
781
798
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
782
799
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
@@ -835,7 +852,10 @@ var OwneySDK = class {
835
852
  if (valid.length === agents.length) {
836
853
  return splits.map((s) => ({ agent: s.agent, amount: String(s.amount) }));
837
854
  }
838
- return this.splitDepositAmount(totalAmount, valid.map((s) => s.agent));
855
+ return this.splitDepositAmount(
856
+ totalAmount,
857
+ valid.map((s) => s.agent)
858
+ );
839
859
  }
840
860
  validateMinDepositAmount(agent, amount) {
841
861
  const minDepositAmount = BigInt(agent.minDepositAmount);
package/dist/index.d.cts CHANGED
@@ -130,6 +130,7 @@ interface OwneyBalances {
130
130
  interface AgentEarnings {
131
131
  smartWallet: `0x${string}`;
132
132
  lifetimeEarnings: number;
133
+ tokens: OwneyToken[];
133
134
  }
134
135
  interface OwneyEarnings {
135
136
  totalEarnings: string;
@@ -249,7 +250,7 @@ declare class OwneySDK {
249
250
  activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
250
251
  /**
251
252
  * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
252
- * Validates that the asset is supported and amount meets minimums for the target agent(s).
253
+ * Validates that the asset is supported and amount meets minimums for the target agent(s).
253
254
  * @param options - Deposit parameters
254
255
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
255
256
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
package/dist/index.d.ts CHANGED
@@ -130,6 +130,7 @@ interface OwneyBalances {
130
130
  interface AgentEarnings {
131
131
  smartWallet: `0x${string}`;
132
132
  lifetimeEarnings: number;
133
+ tokens: OwneyToken[];
133
134
  }
134
135
  interface OwneyEarnings {
135
136
  totalEarnings: string;
@@ -249,7 +250,7 @@ declare class OwneySDK {
249
250
  activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
250
251
  /**
251
252
  * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
252
- * Validates that the asset is supported and amount meets minimums for the target agent(s).
253
+ * Validates that the asset is supported and amount meets minimums for the target agent(s).
253
254
  * @param options - Deposit parameters
254
255
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
255
256
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
package/dist/index.js CHANGED
@@ -156,9 +156,26 @@ function sumTokenEarnings(tokens) {
156
156
  return Object.values(tokens).reduce((sum, val) => sum + Number(val), 0);
157
157
  }
158
158
  function mapEarnings(raw, smartWallet) {
159
+ const totalEarningsByChain = raw.data.totalEarningsByChain;
160
+ const tokens = [];
161
+ for (const [chainIdKey, tokensBySymbol] of Object.entries(
162
+ totalEarningsByChain
163
+ )) {
164
+ const positionChainId = Number(chainIdKey);
165
+ for (const [symbol, earnings] of Object.entries(tokensBySymbol ?? {})) {
166
+ const amount = Number(earnings);
167
+ tokens.push({
168
+ chain: CHAIN_ID_TO_NAME[positionChainId] ?? "BASE",
169
+ chainId: positionChainId,
170
+ asset: symbol,
171
+ amount: String(amount)
172
+ });
173
+ }
174
+ }
159
175
  return {
160
176
  smartWallet,
161
- lifetimeEarnings: sumTokenEarnings(raw.data.totalEarningsByToken)
177
+ lifetimeEarnings: sumTokenEarnings(raw.data.totalEarningsByToken),
178
+ tokens
162
179
  };
163
180
  }
164
181
  function mapApyHistory(raw) {
@@ -746,7 +763,7 @@ var OwneySDK = class {
746
763
  }
747
764
  /**
748
765
  * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
749
- * Validates that the asset is supported and amount meets minimums for the target agent(s).
766
+ * Validates that the asset is supported and amount meets minimums for the target agent(s).
750
767
  * @param options - Deposit parameters
751
768
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
752
769
  * @param options.asset - Asset symbol to deposit (e.g. "USDC")
@@ -805,7 +822,10 @@ var OwneySDK = class {
805
822
  if (valid.length === agents.length) {
806
823
  return splits.map((s) => ({ agent: s.agent, amount: String(s.amount) }));
807
824
  }
808
- return this.splitDepositAmount(totalAmount, valid.map((s) => s.agent));
825
+ return this.splitDepositAmount(
826
+ totalAmount,
827
+ valid.map((s) => s.agent)
828
+ );
809
829
  }
810
830
  validateMinDepositAmount(agent, amount) {
811
831
  const minDepositAmount = BigInt(agent.minDepositAmount);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "dev": "tsup --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@zyfai/sdk": "^0.2.30",
23
+ "@zyfai/sdk": "^0.2.32",
24
24
  "viem": "^2.48.1"
25
25
  },
26
26
  "devDependencies": {
@@ -31,4 +31,4 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  }
34
- }
34
+ }