@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.
- package/dist/adapters/index.cjs +4 -25
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +4 -25
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-CrLRqDFL.d.cts → index-UOQejD-B.d.cts} +1 -1
- package/dist/{index-CrLRqDFL.d.ts → index-UOQejD-B.d.ts} +1 -1
- package/dist/index.cjs +7 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +7 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
// --
|
|
3224
|
-
async
|
|
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
|
|
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);
|