@t2000/sdk 0.16.14 → 0.16.16

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
@@ -2135,7 +2135,7 @@ var SuilendAdapter = class {
2135
2135
  const deposited = dep ? dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals : 0;
2136
2136
  const effectiveAmount = Math.min(amount, deposited);
2137
2137
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on Suilend`);
2138
- const ctokenAmount = dep && effectiveAmount >= deposited * 0.999 ? dep.ctokenAmount : Math.floor(effectiveAmount * 10 ** reserve.mintDecimals / ratio);
2138
+ const rawAmount = Math.floor(effectiveAmount * 10 ** reserve.mintDecimals);
2139
2139
  const tx = new transactions.Transaction();
2140
2140
  tx.setSender(address);
2141
2141
  const [ctokens] = tx.moveCall({
@@ -2146,7 +2146,7 @@ var SuilendAdapter = class {
2146
2146
  tx.pure.u64(reserve.arrayIndex),
2147
2147
  tx.object(caps[0].id),
2148
2148
  tx.object(CLOCK2),
2149
- tx.pure.u64(ctokenAmount)
2149
+ tx.pure.u64(rawAmount)
2150
2150
  ]
2151
2151
  });
2152
2152
  const exemptionType = `${SUILEND_PACKAGE}::lending_market::RateLimiterExemption<${LENDING_MARKET_TYPE}, ${assetInfo.type}>`;
@@ -2182,7 +2182,7 @@ var SuilendAdapter = class {
2182
2182
  const deposited = dep ? dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals : 0;
2183
2183
  const effectiveAmount = Math.min(amount, deposited);
2184
2184
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on Suilend`);
2185
- const ctokenAmount = dep && effectiveAmount >= deposited * 0.999 ? dep.ctokenAmount : Math.floor(effectiveAmount * 10 ** reserve.mintDecimals / ratio);
2185
+ const rawAmount = Math.floor(effectiveAmount * 10 ** reserve.mintDecimals);
2186
2186
  const [ctokens] = tx.moveCall({
2187
2187
  target: `${pkg}::lending_market::withdraw_ctokens`,
2188
2188
  typeArguments: [LENDING_MARKET_TYPE, assetInfo.type],
@@ -2191,7 +2191,7 @@ var SuilendAdapter = class {
2191
2191
  tx.pure.u64(reserve.arrayIndex),
2192
2192
  tx.object(caps[0].id),
2193
2193
  tx.object(CLOCK2),
2194
- tx.pure.u64(ctokenAmount)
2194
+ tx.pure.u64(rawAmount)
2195
2195
  ]
2196
2196
  });
2197
2197
  const exemptionType = `${SUILEND_PACKAGE}::lending_market::RateLimiterExemption<${LENDING_MARKET_TYPE}, ${assetInfo.type}>`;
@@ -3447,15 +3447,21 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
3447
3447
  investmentCostBasis += pos.costBasis;
3448
3448
  }
3449
3449
  }
3450
+ let strategySuiTotal = 0;
3450
3451
  for (const key of this.portfolio.getAllStrategyKeys()) {
3451
3452
  for (const sp of this.portfolio.getStrategyPositions(key)) {
3452
3453
  if (!(sp.asset in INVESTMENT_ASSETS)) continue;
3453
- if (sp.asset === "SUI") continue;
3454
3454
  const price = assetPrices[sp.asset] ?? 0;
3455
3455
  investmentValue += sp.totalAmount * price;
3456
3456
  investmentCostBasis += sp.costBasis;
3457
+ if (sp.asset === "SUI") strategySuiTotal += sp.totalAmount;
3457
3458
  }
3458
3459
  }
3460
+ if (strategySuiTotal > 0) {
3461
+ const suiPrice2 = assetPrices["SUI"] ?? 0;
3462
+ const gasSui = Math.max(0, bal.gasReserve.sui - strategySuiTotal);
3463
+ bal.gasReserve = { sui: gasSui, usdEquiv: gasSui * suiPrice2 };
3464
+ }
3459
3465
  bal.investment = investmentValue;
3460
3466
  bal.investmentPnL = investmentValue - investmentCostBasis;
3461
3467
  } catch {