@t2000/cli 0.22.17 → 0.22.19

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.
@@ -67295,6 +67295,34 @@ var T2000 = class _T2000 extends import_index.default {
67295
67295
  const priceImpact = expectedOutput > 0 ? Math.abs(actualReceived - expectedOutput) / expectedOutput : 0;
67296
67296
  reportFee(this._address, "swap", fee.amount, fee.rate, gasResult.digest);
67297
67297
  this.emitBalanceChange(fromAsset, swapAmount, "swap", gasResult.digest);
67298
+ const stableSet = new Set(STABLE_ASSETS);
67299
+ if (!params._skipPortfolioRecord && stableSet.has(fromAsset) && toAsset in INVESTMENT_ASSETS && actualReceived > 0) {
67300
+ const price = swapAmount / actualReceived;
67301
+ this.portfolio.recordBuy({
67302
+ id: `swap_${Date.now()}`,
67303
+ type: "buy",
67304
+ asset: toAsset,
67305
+ amount: actualReceived,
67306
+ price,
67307
+ usdValue: swapAmount,
67308
+ fee: fee.amount,
67309
+ tx: gasResult.digest,
67310
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
67311
+ });
67312
+ } else if (!params._skipPortfolioRecord && fromAsset in INVESTMENT_ASSETS && stableSet.has(toAsset) && actualReceived > 0) {
67313
+ const price = actualReceived / swapAmount;
67314
+ this.portfolio.recordSell({
67315
+ id: `swap_${Date.now()}`,
67316
+ type: "sell",
67317
+ asset: fromAsset,
67318
+ amount: swapAmount,
67319
+ price,
67320
+ usdValue: actualReceived,
67321
+ fee: fee.amount,
67322
+ tx: gasResult.digest,
67323
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
67324
+ });
67325
+ }
67298
67326
  return {
67299
67327
  success: true,
67300
67328
  tx: gasResult.digest,
@@ -67352,7 +67380,8 @@ var T2000 = class _T2000 extends import_index.default {
67352
67380
  from: "USDC",
67353
67381
  to: params.asset,
67354
67382
  amount: params.usdAmount,
67355
- maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset)
67383
+ maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset),
67384
+ _skipPortfolioRecord: true
67356
67385
  });
67357
67386
  break;
67358
67387
  } catch (err) {
@@ -67472,7 +67501,8 @@ var T2000 = class _T2000 extends import_index.default {
67472
67501
  from: params.asset,
67473
67502
  to: "USDC",
67474
67503
  amount: sellAmountAsset,
67475
- maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset)
67504
+ maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset),
67505
+ _skipPortfolioRecord: true
67476
67506
  });
67477
67507
  break;
67478
67508
  } catch (err) {
@@ -69077,4 +69107,4 @@ lodash/lodash.js:
69077
69107
  @scure/bip39/index.js:
69078
69108
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
69079
69109
  */
69080
- //# sourceMappingURL=chunk-4FTMWFBO.js.map
69110
+ //# sourceMappingURL=chunk-L6CQW3XK.js.map