@t2000/sdk 0.9.9 → 0.10.0
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.js +4 -25
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +4 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
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: [
|