@owney/sdk 0.7.26-beta.6 → 0.7.26-beta.7

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
@@ -303,6 +303,15 @@ var DayFilterMapping = {
303
303
  "7D": 7
304
304
  };
305
305
 
306
+ // src/lib/helpers/asset-aliases.ts
307
+ function assetAliases(asset) {
308
+ const normalised = asset.toLowerCase();
309
+ return normalised === "weth" ? ["weth", "eth"] : [normalised];
310
+ }
311
+ function matchesAsset(symbol, asset) {
312
+ return assetAliases(asset).includes(symbol.toLowerCase());
313
+ }
314
+
306
315
  // src/agents/zyfai/zyfai.mapper.ts
307
316
  var DECIMALS_BY_SYMBOL = {
308
317
  usdc: 6,
@@ -707,9 +716,8 @@ function computeAllocationApy(positions) {
707
716
  function earningsForToken(bucket, chainId, asset) {
708
717
  const tokens = bucket?.[String(chainId)];
709
718
  if (!tokens) return null;
710
- const wanted = asset.toUpperCase();
711
719
  for (const [symbol, value] of Object.entries(tokens)) {
712
- if (symbol.toUpperCase() !== wanted) continue;
720
+ if (!matchesAsset(symbol, asset)) continue;
713
721
  const amount = Number(value);
714
722
  return Number.isFinite(amount) ? amount : null;
715
723
  }
@@ -3537,11 +3545,10 @@ async function withFailureReporting(apiKey, agentType, fn, baseUrl) {
3537
3545
  // src/lib/helpers/withdraw-helper.ts
3538
3546
  var import_viem6 = require("viem");
3539
3547
  function projectAgentBalancesForAsset(agents, aggregated, chainId, asset, decimals) {
3540
- const target = asset.toUpperCase();
3541
3548
  return agents.map((agent) => {
3542
3549
  const agentBalance = aggregated[agent.id];
3543
3550
  const tokenBalance = agentBalance?.tokens.find(
3544
- (t) => t.chainId === chainId && t.asset.toUpperCase() === target
3551
+ (t) => t.chainId === chainId && matchesAsset(t.asset, asset)
3545
3552
  );
3546
3553
  if (!tokenBalance) return { agent, balance: 0n };
3547
3554
  return { agent, balance: (0, import_viem6.parseUnits)(tokenBalance.amount, decimals) };
@@ -4842,15 +4849,14 @@ var OwneySDK = class {
4842
4849
  async hasExistingBalance(agent, state, chainId, asset, requireReliableRead = false) {
4843
4850
  try {
4844
4851
  const balance = await agent.getBalances(state, chainId);
4845
- const target = asset.toLowerCase();
4846
4852
  const token = balance.tokens.find(
4847
- (t) => t.chainId === chainId && t.asset.toLowerCase() === target
4853
+ (t) => t.chainId === chainId && matchesAsset(t.asset, asset)
4848
4854
  );
4849
4855
  const targetChainName = agent.supportedAssets.find((entry) => entry.chainId === chainId)?.chain?.trim().toUpperCase();
4850
4856
  const position = (balance.positions ?? []).find((p) => {
4851
4857
  const positionChain = p.chain.trim().toUpperCase();
4852
4858
  const matchesChain = positionChain === String(chainId) || targetChainName !== void 0 && positionChain === targetChainName;
4853
- return matchesChain && p.asset.toLowerCase() === target && Number(p.amount) > 0;
4859
+ return matchesChain && matchesAsset(p.asset, asset) && Number(p.amount) > 0;
4854
4860
  });
4855
4861
  return !!token && Number(token.amount) > 0 || !!position;
4856
4862
  } catch (error) {
package/dist/index.js CHANGED
@@ -263,6 +263,15 @@ var DayFilterMapping = {
263
263
  "7D": 7
264
264
  };
265
265
 
266
+ // src/lib/helpers/asset-aliases.ts
267
+ function assetAliases(asset) {
268
+ const normalised = asset.toLowerCase();
269
+ return normalised === "weth" ? ["weth", "eth"] : [normalised];
270
+ }
271
+ function matchesAsset(symbol, asset) {
272
+ return assetAliases(asset).includes(symbol.toLowerCase());
273
+ }
274
+
266
275
  // src/agents/zyfai/zyfai.mapper.ts
267
276
  var DECIMALS_BY_SYMBOL = {
268
277
  usdc: 6,
@@ -667,9 +676,8 @@ function computeAllocationApy(positions) {
667
676
  function earningsForToken(bucket, chainId, asset) {
668
677
  const tokens = bucket?.[String(chainId)];
669
678
  if (!tokens) return null;
670
- const wanted = asset.toUpperCase();
671
679
  for (const [symbol, value] of Object.entries(tokens)) {
672
- if (symbol.toUpperCase() !== wanted) continue;
680
+ if (!matchesAsset(symbol, asset)) continue;
673
681
  const amount = Number(value);
674
682
  return Number.isFinite(amount) ? amount : null;
675
683
  }
@@ -3512,11 +3520,10 @@ async function withFailureReporting(apiKey, agentType, fn, baseUrl) {
3512
3520
  // src/lib/helpers/withdraw-helper.ts
3513
3521
  import { parseUnits } from "viem";
3514
3522
  function projectAgentBalancesForAsset(agents, aggregated, chainId, asset, decimals) {
3515
- const target = asset.toUpperCase();
3516
3523
  return agents.map((agent) => {
3517
3524
  const agentBalance = aggregated[agent.id];
3518
3525
  const tokenBalance = agentBalance?.tokens.find(
3519
- (t) => t.chainId === chainId && t.asset.toUpperCase() === target
3526
+ (t) => t.chainId === chainId && matchesAsset(t.asset, asset)
3520
3527
  );
3521
3528
  if (!tokenBalance) return { agent, balance: 0n };
3522
3529
  return { agent, balance: parseUnits(tokenBalance.amount, decimals) };
@@ -4823,15 +4830,14 @@ var OwneySDK = class {
4823
4830
  async hasExistingBalance(agent, state, chainId, asset, requireReliableRead = false) {
4824
4831
  try {
4825
4832
  const balance = await agent.getBalances(state, chainId);
4826
- const target = asset.toLowerCase();
4827
4833
  const token = balance.tokens.find(
4828
- (t) => t.chainId === chainId && t.asset.toLowerCase() === target
4834
+ (t) => t.chainId === chainId && matchesAsset(t.asset, asset)
4829
4835
  );
4830
4836
  const targetChainName = agent.supportedAssets.find((entry) => entry.chainId === chainId)?.chain?.trim().toUpperCase();
4831
4837
  const position = (balance.positions ?? []).find((p) => {
4832
4838
  const positionChain = p.chain.trim().toUpperCase();
4833
4839
  const matchesChain = positionChain === String(chainId) || targetChainName !== void 0 && positionChain === targetChainName;
4834
- return matchesChain && p.asset.toLowerCase() === target && Number(p.amount) > 0;
4840
+ return matchesChain && matchesAsset(p.asset, asset) && Number(p.amount) > 0;
4835
4841
  });
4836
4842
  return !!token && Number(token.amount) > 0 || !!position;
4837
4843
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.26-beta.6",
3
+ "version": "0.7.26-beta.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",