@t2000/sdk 0.9.9 → 0.10.1

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.
@@ -509,4 +509,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
509
509
  /** All registered protocol descriptors — used by the indexer for event classification */
510
510
  declare const allDescriptors: ProtocolDescriptor[];
511
511
 
512
- export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, listSentinels as I, descriptor$3 as J, requestAttack as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, attack as O, type PositionsResult as P, descriptor as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, settleAttack as U, submitPrompt as V, type WithdrawResult as W, descriptor$1 as X, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type RatesResult as f, type LendingRates as g, type RebalanceResult as h, type SentinelAgent as i, type SentinelAttackResult as j, type AdapterPositions as k, type AdapterTxResult as l, type AssetRates as m, type GasReserve as n, type HealthInfo as o, type PositionEntry as p, type ProtocolDescriptor as q, ProtocolRegistry as r, type RebalanceStep as s, type SentinelVerdict as t, SuilendAdapter as u, type SwapQuote as v, type SwapResult as w, allDescriptors as x, descriptor$2 as y, getSentinelInfo as z };
512
+ export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, listSentinels as I, descriptor$3 as J, requestAttack as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, attack as O, type PositionsResult as P, descriptor as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, settleAttack as U, submitPrompt as V, type WithdrawResult as W, descriptor$1 as X, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type RatesResult as g, type LendingRates as h, type RebalanceResult as i, type SentinelAgent as j, type SentinelAttackResult as k, type AdapterPositions as l, type AdapterTxResult as m, type AssetRates as n, type GasReserve as o, type HealthInfo as p, type PositionEntry as q, type ProtocolDescriptor as r, ProtocolRegistry as s, type RebalanceStep as t, type SentinelVerdict as u, SuilendAdapter as v, type SwapQuote as w, allDescriptors as x, descriptor$2 as y, getSentinelInfo as z };
@@ -509,4 +509,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
509
509
  /** All registered protocol descriptors — used by the indexer for event classification */
510
510
  declare const allDescriptors: ProtocolDescriptor[];
511
511
 
512
- export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, listSentinels as I, descriptor$3 as J, requestAttack as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, attack as O, type PositionsResult as P, descriptor as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, settleAttack as U, submitPrompt as V, type WithdrawResult as W, descriptor$1 as X, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type RatesResult as f, type LendingRates as g, type RebalanceResult as h, type SentinelAgent as i, type SentinelAttackResult as j, type AdapterPositions as k, type AdapterTxResult as l, type AssetRates as m, type GasReserve as n, type HealthInfo as o, type PositionEntry as p, type ProtocolDescriptor as q, ProtocolRegistry as r, type RebalanceStep as s, type SentinelVerdict as t, SuilendAdapter as u, type SwapQuote as v, type SwapResult as w, allDescriptors as x, descriptor$2 as y, getSentinelInfo as z };
512
+ export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, listSentinels as I, descriptor$3 as J, requestAttack as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, attack as O, type PositionsResult as P, descriptor as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, settleAttack as U, submitPrompt as V, type WithdrawResult as W, descriptor$1 as X, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type RatesResult as g, type LendingRates as h, type RebalanceResult as i, type SentinelAgent as j, type SentinelAttackResult as k, type AdapterPositions as l, type AdapterTxResult as m, type AssetRates as n, type GasReserve as o, type HealthInfo as p, type PositionEntry as q, type ProtocolDescriptor as r, ProtocolRegistry as s, type RebalanceStep as t, type SentinelVerdict as u, SuilendAdapter as v, type SwapQuote as w, allDescriptors as x, descriptor$2 as y, getSentinelInfo as z };
package/dist/index.cjs CHANGED
@@ -11,7 +11,6 @@ var promises = require('fs/promises');
11
11
  var path = require('path');
12
12
  var os = require('os');
13
13
  var bcs = require('@mysten/sui/bcs');
14
- var pythSuiJs = require('@pythnetwork/pyth-sui-js');
15
14
  var aggregatorSdk = require('@cetusprotocol/aggregator-sdk');
16
15
 
17
16
  // src/t2000.ts
@@ -511,7 +510,6 @@ var NAVI_BALANCE_DECIMALS = 9;
511
510
  var CONFIG_API = "https://open-api.naviprotocol.io/api/navi/config?env=prod";
512
511
  var POOLS_API = "https://open-api.naviprotocol.io/api/navi/pools?env=prod";
513
512
  var PACKAGE_API = "https://open-api.naviprotocol.io/api/package";
514
- var PYTH_HERMES_URL = "https://hermes.pyth.network/";
515
513
  var packageCache = null;
516
514
  function toBigInt(v) {
517
515
  if (typeof v === "bigint") return v;
@@ -606,31 +604,12 @@ function addOracleUpdate(tx, config, pool) {
606
604
  ]
607
605
  });
608
606
  }
609
- async function refreshStableOracles(tx, client, config, pools) {
607
+ function refreshStableOracles(tx, config, pools) {
610
608
  const stableTypes = STABLE_ASSETS.map((a) => SUPPORTED_ASSETS[a].type);
611
609
  const stablePools = pools.filter((p) => {
612
610
  const ct = p.suiCoinType || p.coinType || "";
613
611
  return stableTypes.some((t) => matchesCoinType(ct, t));
614
612
  });
615
- const feeds = (config.oracle.feeds ?? []).filter(
616
- (f2) => stablePools.some((p) => p.id === f2.assetId)
617
- );
618
- if (feeds.length === 0) return;
619
- const pythFeedIds = feeds.map((f2) => f2.pythPriceFeedId).filter(Boolean);
620
- if (pythFeedIds.length > 0 && config.oracle.pythStateId && config.oracle.wormholeStateId) {
621
- try {
622
- const connection = new pythSuiJs.SuiPriceServiceConnection(PYTH_HERMES_URL);
623
- const priceUpdateData = await connection.getPriceFeedsUpdateData(pythFeedIds);
624
- const pythClient = new pythSuiJs.SuiPythClient(
625
- client,
626
- config.oracle.pythStateId,
627
- config.oracle.wormholeStateId
628
- );
629
- await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
630
- } catch (err) {
631
- console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
632
- }
633
- }
634
613
  for (const pool of stablePools) {
635
614
  addOracleUpdate(tx, config, pool);
636
615
  }
@@ -751,7 +730,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
751
730
  }
752
731
  const tx = new transactions.Transaction();
753
732
  tx.setSender(address);
754
- await refreshStableOracles(tx, client, config, pools);
733
+ refreshStableOracles(tx, config, pools);
755
734
  const [balance] = tx.moveCall({
756
735
  target: `${config.package}::incentive_v3::withdraw_v2`,
757
736
  arguments: [
@@ -796,7 +775,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
796
775
  });
797
776
  return { coin: coin2, effectiveAmount: 0 };
798
777
  }
799
- await refreshStableOracles(tx, client, config, pools);
778
+ refreshStableOracles(tx, config, pools);
800
779
  const [balance] = tx.moveCall({
801
780
  target: `${config.package}::incentive_v3::withdraw_v2`,
802
781
  arguments: [
@@ -884,7 +863,7 @@ async function buildBorrowTx(client, address, amount, options = {}) {
884
863
  ]);
885
864
  const tx = new transactions.Transaction();
886
865
  tx.setSender(address);
887
- await refreshStableOracles(tx, client, config, pools);
866
+ refreshStableOracles(tx, config, pools);
888
867
  const [balance] = tx.moveCall({
889
868
  target: `${config.package}::incentive_v3::borrow_v2`,
890
869
  arguments: [
@@ -3220,8 +3199,8 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
3220
3199
  }
3221
3200
  return hf;
3222
3201
  }
3223
- // -- Swap (internal — used by rebalance and withdraw auto-swap) --
3224
- async _swap(params) {
3202
+ // -- Exchange --
3203
+ async exchange(params) {
3225
3204
  const fromAsset = params.from;
3226
3205
  const toAsset = params.to;
3227
3206
  if (!(fromAsset in SUPPORTED_ASSETS) || !(toAsset in SUPPORTED_ASSETS)) {
@@ -3274,7 +3253,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
3274
3253
  gasMethod: gasResult.gasMethod
3275
3254
  };
3276
3255
  }
3277
- async _swapQuote(params) {
3256
+ async exchangeQuote(params) {
3278
3257
  const fromAsset = params.from;
3279
3258
  const toAsset = params.to;
3280
3259
  const best = await this.registry.bestSwapQuote(fromAsset, toAsset, params.amount);