@t2000/sdk 0.17.1 → 0.17.3
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 +4 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3027,9 +3027,6 @@ var PortfolioManager = class {
|
|
|
3027
3027
|
if (!pos || pos.totalAmount <= 0) {
|
|
3028
3028
|
throw new T2000Error("INSUFFICIENT_INVESTMENT", `No ${asset} position to earn on`);
|
|
3029
3029
|
}
|
|
3030
|
-
if (pos.earning) {
|
|
3031
|
-
throw new T2000Error("INVEST_ALREADY_EARNING", `${asset} is already earning via ${pos.earningProtocol}`);
|
|
3032
|
-
}
|
|
3033
3030
|
pos.earning = true;
|
|
3034
3031
|
pos.earningProtocol = protocol;
|
|
3035
3032
|
pos.earningApy = apy;
|
|
@@ -4439,10 +4436,6 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4439
4436
|
if (!pos || pos.totalAmount <= 0) {
|
|
4440
4437
|
throw new T2000Error("INSUFFICIENT_INVESTMENT", `No ${params.asset} position to earn on`);
|
|
4441
4438
|
}
|
|
4442
|
-
if (pos.earning) {
|
|
4443
|
-
throw new T2000Error("INVEST_ALREADY_EARNING", `${params.asset} is already earning via ${pos.earningProtocol}`);
|
|
4444
|
-
}
|
|
4445
|
-
const { adapter, rate } = await this.registry.bestSaveRate(params.asset);
|
|
4446
4439
|
const assetInfo = SUPPORTED_ASSETS[params.asset];
|
|
4447
4440
|
const assetBalance = await this.client.getBalance({
|
|
4448
4441
|
owner: this._address,
|
|
@@ -4451,9 +4444,13 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
4451
4444
|
const walletAmount = Number(assetBalance.totalBalance) / 10 ** assetInfo.decimals;
|
|
4452
4445
|
const gasReserve = params.asset === "SUI" ? GAS_RESERVE_MIN : 0;
|
|
4453
4446
|
const depositAmount = Math.max(0, walletAmount - gasReserve);
|
|
4447
|
+
if (pos.earning && depositAmount <= 0) {
|
|
4448
|
+
throw new T2000Error("INVEST_ALREADY_EARNING", `${params.asset} is already earning via ${pos.earningProtocol}`);
|
|
4449
|
+
}
|
|
4454
4450
|
if (depositAmount <= 0) {
|
|
4455
4451
|
throw new T2000Error("INSUFFICIENT_BALANCE", `No ${params.asset} available to deposit (wallet: ${walletAmount}, gas reserve: ${gasReserve})`);
|
|
4456
4452
|
}
|
|
4453
|
+
const { adapter, rate } = await this.registry.bestSaveRate(params.asset);
|
|
4457
4454
|
const gasResult = await executeWithGas(this.client, this.keypair, async () => {
|
|
4458
4455
|
const { tx } = await adapter.buildSaveTx(this._address, depositAmount, params.asset);
|
|
4459
4456
|
return tx;
|