@t2000/sdk 0.17.16 → 0.17.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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-xQEri-Eu.cjs';
2
- export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-xQEri-Eu.cjs';
1
+ import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-Dl9CthNB.cjs';
2
+ export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-Dl9CthNB.cjs';
3
3
  import { EventEmitter } from 'eventemitter3';
4
4
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
5
5
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-xQEri-Eu.js';
2
- export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-xQEri-Eu.js';
1
+ import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, P as PendingReward, C as ClaimRewardsResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, p as PortfolioResult, q as InvestmentPosition, r as PositionsResult, s as RatesResult, t as LendingRates, u as RebalanceResult, E as EarningsResult, F as FundStatusResult, v as SentinelAgent, w as SentinelAttackResult, G as GasMethod } from './index-Dl9CthNB.js';
2
+ export { x as AdapterCapability, y as AdapterPositions, z as AdapterTxResult, J as AssetRates, K as CetusAdapter, N as GasReserve, O as HealthInfo, Q as NaviAdapter, U as PerpsAdapter, V as PerpsPosition, X as PositionEntry, Y as PositionSide, Z as ProtocolDescriptor, _ as ProtocolRegistry, $ as RebalanceStep, a0 as SentinelVerdict, a1 as SuilendAdapter, a2 as SwapQuote, a3 as TradePositionsResult, a4 as TradeResult, a5 as allDescriptors, a6 as cetusDescriptor, a7 as getSentinelInfo, a8 as listSentinels, a9 as naviDescriptor, aa as requestAttack, ab as sentinelAttack, ac as sentinelDescriptor, ad as settleAttack, ae as submitPrompt, af as suilendDescriptor } from './index-Dl9CthNB.js';
3
3
  import { EventEmitter } from 'eventemitter3';
4
4
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
5
5
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
package/dist/index.js CHANGED
@@ -1244,15 +1244,13 @@ function stripPrefix(coinType) {
1244
1244
  return coinType.replace(/^0x0*/, "");
1245
1245
  }
1246
1246
  async function getPendingRewards(client, address) {
1247
- const [pools, states, rules] = await Promise.all([
1247
+ const [pools, states] = await Promise.all([
1248
1248
  getPools(),
1249
- getUserState(client, address),
1250
- getIncentiveRules(client)
1249
+ getUserState(client, address)
1251
1250
  ]);
1252
1251
  const rewards = [];
1253
1252
  const deposited = states.filter((s) => s.supplyBalance > 0n);
1254
1253
  if (deposited.length === 0) return rewards;
1255
- const rewardTotals = /* @__PURE__ */ new Map();
1256
1254
  for (const state of deposited) {
1257
1255
  const pool = pools.find((p) => p.id === state.assetId);
1258
1256
  if (!pool) continue;
@@ -1261,20 +1259,14 @@ async function getPendingRewards(client, address) {
1261
1259
  const rewardCoins = pool.supplyIncentiveApyInfo?.rewardCoin;
1262
1260
  if (!Array.isArray(rewardCoins) || rewardCoins.length === 0) continue;
1263
1261
  const rewardType = rewardCoins[0];
1264
- const supplyBal = compoundBalance(state.supplyBalance, pool.currentSupplyIndex, pool);
1265
- const price = pool.token?.price ?? 0;
1266
- const depositUsd = supplyBal * price;
1267
- const annualRewardUsd = depositUsd * (boostedApr / 100);
1268
- const estimatedUsd = annualRewardUsd / 365;
1269
- rewardTotals.set(rewardType, (rewardTotals.get(rewardType) ?? 0) + estimatedUsd);
1270
- }
1271
- for (const [coinType, dailyUsd] of rewardTotals) {
1262
+ const assetSymbol = resolvePoolSymbol(pool);
1272
1263
  rewards.push({
1273
1264
  protocol: "navi",
1274
- coinType,
1275
- symbol: REWARD_SYMBOLS[coinType] ?? coinType.split("::").pop() ?? "UNKNOWN",
1265
+ asset: assetSymbol,
1266
+ coinType: rewardType,
1267
+ symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
1276
1268
  amount: 0,
1277
- estimatedValueUsd: dailyUsd
1269
+ estimatedValueUsd: 0
1278
1270
  });
1279
1271
  }
1280
1272
  return rewards;
@@ -1335,6 +1327,7 @@ async function addClaimRewardsToTx(tx, client, address) {
1335
1327
  tx.transferObjects([coin], address);
1336
1328
  claimed.push({
1337
1329
  protocol: "navi",
1330
+ asset: assets.join(", "),
1338
1331
  coinType: rewardType,
1339
1332
  symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
1340
1333
  amount: 0,
@@ -2695,45 +2688,24 @@ var SuilendAdapter = class {
2695
2688
  this.fetchObligation(caps[0].obligationId)
2696
2689
  ]);
2697
2690
  const rewards = [];
2698
- const rewardEstimates = /* @__PURE__ */ new Map();
2699
2691
  for (const dep of obligation.deposits) {
2700
2692
  const reserve = reserves[dep.reserveIdx];
2701
2693
  if (!reserve) continue;
2702
- const ratio = cTokenRatio(reserve);
2703
- const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
2704
- const price = reserve.price;
2705
- const depositUsd = amount * price;
2706
2694
  for (const rw of reserve.depositPoolRewards) {
2707
2695
  if (!this.isClaimableReward(rw.coinType)) continue;
2708
- const rewardReserve = reserves.find((r) => {
2709
- try {
2710
- return normalizeStructTag(r.coinType) === normalizeStructTag(rw.coinType);
2711
- } catch {
2712
- return false;
2713
- }
2714
- });
2715
- const rewardPrice = rewardReserve?.price ?? 0;
2716
- const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
2717
2696
  const durationMs = rw.endTimeMs - rw.startTimeMs;
2718
2697
  if (durationMs <= 0) continue;
2719
- const annualTokens = rw.totalRewards / 10 ** rewardDecimals * (MS_PER_YEAR / durationMs);
2720
- const totalDepositValue = reserve.depositTotalShares / 10 ** reserve.mintDecimals * price;
2721
- if (totalDepositValue <= 0) continue;
2722
- const userShare = depositUsd / totalDepositValue;
2723
- const dailyRewardUsd = annualTokens * rewardPrice / 365 * userShare;
2724
- rewardEstimates.set(rw.coinType, (rewardEstimates.get(rw.coinType) ?? 0) + dailyRewardUsd);
2698
+ const assetSymbol = this.resolveSymbol(reserve.coinType);
2699
+ rewards.push({
2700
+ protocol: "suilend",
2701
+ asset: assetSymbol,
2702
+ coinType: rw.coinType,
2703
+ symbol: rw.coinType.includes("spring_sui") ? "sSUI" : rw.coinType.includes("deep::") ? "DEEP" : rw.coinType.split("::").pop() ?? "UNKNOWN",
2704
+ amount: 0,
2705
+ estimatedValueUsd: 0
2706
+ });
2725
2707
  }
2726
2708
  }
2727
- for (const [coinType, dailyUsd] of rewardEstimates) {
2728
- const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
2729
- rewards.push({
2730
- protocol: "suilend",
2731
- coinType,
2732
- symbol,
2733
- amount: 0,
2734
- estimatedValueUsd: dailyUsd
2735
- });
2736
- }
2737
2709
  return rewards;
2738
2710
  }
2739
2711
  async addClaimRewardsToTx(tx, address) {
@@ -2776,6 +2748,7 @@ var SuilendAdapter = class {
2776
2748
  const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
2777
2749
  claimed.push({
2778
2750
  protocol: "suilend",
2751
+ asset: "",
2779
2752
  coinType,
2780
2753
  symbol,
2781
2754
  amount: 0,