@owney/sdk 0.7.8 → 0.7.9

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.cjs CHANGED
@@ -250,9 +250,10 @@ function mapBalances(raw, _chainId, smartWallet) {
250
250
  const tokens = [];
251
251
  for (const [chainIdKey, tokensBySymbol] of Object.entries(portfolioByChain)) {
252
252
  const positionChainId = Number(chainIdKey);
253
- for (const [symbol, { balance, balanceWithFee, decimals }] of Object.entries(
254
- tokensBySymbol ?? {}
255
- )) {
253
+ for (const [
254
+ symbol,
255
+ { balance, balanceWithFee, decimals }
256
+ ] of Object.entries(tokensBySymbol ?? {})) {
256
257
  const amount = hexToDecimal(balanceWithFee ?? balance ?? "0", decimals);
257
258
  totalBalance += amount;
258
259
  tokens.push({
@@ -391,6 +392,11 @@ function mapEntries(rawEntries, chainId) {
391
392
  "Top up wallet": "Top up",
392
393
  "Partial withdraw from protocol": "Withdraw",
393
394
  "Withdraw from protocol": "Withdraw",
395
+ // The agent's own leg of a top up: the funds the user sent moving into the
396
+ // pool that earns the APY. Zyfai emits it as a separate entry seconds after
397
+ // "Top up wallet" and for slightly less (gas). `Deposit` already exists in
398
+ // the public HistoryAction union, so no consumer type change is needed.
399
+ "Deposit to protocol": "Deposit",
394
400
  Rebalance: "Rebalance"
395
401
  };
396
402
  void chainId;
@@ -431,12 +437,19 @@ function mapEntries(rawEntries, chainId) {
431
437
  const mappedAction = (entry.action ? actionMap[entry.action] : void 0) ?? entry.action;
432
438
  const rawAmount = entry?.positions?.[0]?.amount;
433
439
  const hasAmount = mappedAction !== "Withdraw" && typeof rawAmount === "string" && rawAmount !== "" && rawAmount !== "0x" && rawAmount !== "0x0" && rawAmount !== "0";
440
+ const mappedPositions = positions.filter((p) => p.protocol_name).map((p) => ({
441
+ protocol: p.protocol_name,
442
+ pool: p.pool ?? void 0,
443
+ tokenSymbol: p.token_symbol ?? void 0,
444
+ amount: mappedAction !== "Withdraw" && typeof p.amount === "string" && p.amount !== "" && p.amount !== "0x" ? String(hexToDecimal(p.amount, tokenDecimals(p.token_symbol))) : void 0
445
+ }));
434
446
  return {
435
447
  agent: "zyfai",
436
448
  action: mappedAction,
437
449
  date: entry.date || "",
438
450
  newApy: newApy === null ? null : String(newApy),
439
451
  oldApy: oldApy === null ? null : String(oldApy),
452
+ ...mappedPositions.length ? { positions: mappedPositions } : {},
440
453
  transactions: [
441
454
  {
442
455
  txHashes: entry.transactionHash ? [entry.transactionHash] : [],
@@ -1761,7 +1774,7 @@ var ZyfaiAgent = class {
1761
1774
  toDate
1762
1775
  });
1763
1776
  raw.data.forEach((entry, idx) => {
1764
- if (entry.chainId === validChainId && entry.action !== "Deposit to protocol") {
1777
+ if (entry.chainId === validChainId) {
1765
1778
  matched.push({ entry, rawIdx: offset + idx });
1766
1779
  }
1767
1780
  });
package/dist/index.js CHANGED
@@ -217,9 +217,10 @@ function mapBalances(raw, _chainId, smartWallet) {
217
217
  const tokens = [];
218
218
  for (const [chainIdKey, tokensBySymbol] of Object.entries(portfolioByChain)) {
219
219
  const positionChainId = Number(chainIdKey);
220
- for (const [symbol, { balance, balanceWithFee, decimals }] of Object.entries(
221
- tokensBySymbol ?? {}
222
- )) {
220
+ for (const [
221
+ symbol,
222
+ { balance, balanceWithFee, decimals }
223
+ ] of Object.entries(tokensBySymbol ?? {})) {
223
224
  const amount = hexToDecimal(balanceWithFee ?? balance ?? "0", decimals);
224
225
  totalBalance += amount;
225
226
  tokens.push({
@@ -358,6 +359,11 @@ function mapEntries(rawEntries, chainId) {
358
359
  "Top up wallet": "Top up",
359
360
  "Partial withdraw from protocol": "Withdraw",
360
361
  "Withdraw from protocol": "Withdraw",
362
+ // The agent's own leg of a top up: the funds the user sent moving into the
363
+ // pool that earns the APY. Zyfai emits it as a separate entry seconds after
364
+ // "Top up wallet" and for slightly less (gas). `Deposit` already exists in
365
+ // the public HistoryAction union, so no consumer type change is needed.
366
+ "Deposit to protocol": "Deposit",
361
367
  Rebalance: "Rebalance"
362
368
  };
363
369
  void chainId;
@@ -398,12 +404,19 @@ function mapEntries(rawEntries, chainId) {
398
404
  const mappedAction = (entry.action ? actionMap[entry.action] : void 0) ?? entry.action;
399
405
  const rawAmount = entry?.positions?.[0]?.amount;
400
406
  const hasAmount = mappedAction !== "Withdraw" && typeof rawAmount === "string" && rawAmount !== "" && rawAmount !== "0x" && rawAmount !== "0x0" && rawAmount !== "0";
407
+ const mappedPositions = positions.filter((p) => p.protocol_name).map((p) => ({
408
+ protocol: p.protocol_name,
409
+ pool: p.pool ?? void 0,
410
+ tokenSymbol: p.token_symbol ?? void 0,
411
+ amount: mappedAction !== "Withdraw" && typeof p.amount === "string" && p.amount !== "" && p.amount !== "0x" ? String(hexToDecimal(p.amount, tokenDecimals(p.token_symbol))) : void 0
412
+ }));
401
413
  return {
402
414
  agent: "zyfai",
403
415
  action: mappedAction,
404
416
  date: entry.date || "",
405
417
  newApy: newApy === null ? null : String(newApy),
406
418
  oldApy: oldApy === null ? null : String(oldApy),
419
+ ...mappedPositions.length ? { positions: mappedPositions } : {},
407
420
  transactions: [
408
421
  {
409
422
  txHashes: entry.transactionHash ? [entry.transactionHash] : [],
@@ -1728,7 +1741,7 @@ var ZyfaiAgent = class {
1728
1741
  toDate
1729
1742
  });
1730
1743
  raw.data.forEach((entry, idx) => {
1731
- if (entry.chainId === validChainId && entry.action !== "Deposit to protocol") {
1744
+ if (entry.chainId === validChainId) {
1732
1745
  matched.push({ entry, rawIdx: offset + idx });
1733
1746
  }
1734
1747
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",