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