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