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