@t2000/sdk 0.19.15 → 0.19.17

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
@@ -4415,6 +4415,34 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
4415
4415
  const priceImpact = expectedOutput > 0 ? Math.abs(actualReceived - expectedOutput) / expectedOutput : 0;
4416
4416
  reportFee(this._address, "swap", fee.amount, fee.rate, gasResult.digest);
4417
4417
  this.emitBalanceChange(fromAsset, swapAmount, "swap", gasResult.digest);
4418
+ const stableSet = new Set(STABLE_ASSETS);
4419
+ if (!params._skipPortfolioRecord && stableSet.has(fromAsset) && toAsset in INVESTMENT_ASSETS && actualReceived > 0) {
4420
+ const price = swapAmount / actualReceived;
4421
+ this.portfolio.recordBuy({
4422
+ id: `swap_${Date.now()}`,
4423
+ type: "buy",
4424
+ asset: toAsset,
4425
+ amount: actualReceived,
4426
+ price,
4427
+ usdValue: swapAmount,
4428
+ fee: fee.amount,
4429
+ tx: gasResult.digest,
4430
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
4431
+ });
4432
+ } else if (!params._skipPortfolioRecord && fromAsset in INVESTMENT_ASSETS && stableSet.has(toAsset) && actualReceived > 0) {
4433
+ const price = actualReceived / swapAmount;
4434
+ this.portfolio.recordSell({
4435
+ id: `swap_${Date.now()}`,
4436
+ type: "sell",
4437
+ asset: fromAsset,
4438
+ amount: swapAmount,
4439
+ price,
4440
+ usdValue: actualReceived,
4441
+ fee: fee.amount,
4442
+ tx: gasResult.digest,
4443
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
4444
+ });
4445
+ }
4418
4446
  return {
4419
4447
  success: true,
4420
4448
  tx: gasResult.digest,
@@ -4472,7 +4500,8 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
4472
4500
  from: "USDC",
4473
4501
  to: params.asset,
4474
4502
  amount: params.usdAmount,
4475
- maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset)
4503
+ maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset),
4504
+ _skipPortfolioRecord: true
4476
4505
  });
4477
4506
  break;
4478
4507
  } catch (err) {
@@ -4592,7 +4621,8 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
4592
4621
  from: params.asset,
4593
4622
  to: "USDC",
4594
4623
  amount: sellAmountAsset,
4595
- maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset)
4624
+ maxSlippage: params.maxSlippage ?? defaultSlippage(params.asset),
4625
+ _skipPortfolioRecord: true
4596
4626
  });
4597
4627
  break;
4598
4628
  } catch (err) {