@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.js
CHANGED
|
@@ -9,7 +9,6 @@ import { access, mkdir, writeFile, readFile } from 'fs/promises';
|
|
|
9
9
|
import { dirname, resolve } from 'path';
|
|
10
10
|
import { homedir } from 'os';
|
|
11
11
|
import { bcs } from '@mysten/sui/bcs';
|
|
12
|
-
import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
|
|
13
12
|
import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
|
|
14
13
|
|
|
15
14
|
// src/t2000.ts
|
|
@@ -509,7 +508,6 @@ var NAVI_BALANCE_DECIMALS = 9;
|
|
|
509
508
|
var CONFIG_API = "https://open-api.naviprotocol.io/api/navi/config?env=prod";
|
|
510
509
|
var POOLS_API = "https://open-api.naviprotocol.io/api/navi/pools?env=prod";
|
|
511
510
|
var PACKAGE_API = "https://open-api.naviprotocol.io/api/package";
|
|
512
|
-
var PYTH_HERMES_URL = "https://hermes.pyth.network/";
|
|
513
511
|
var packageCache = null;
|
|
514
512
|
function toBigInt(v) {
|
|
515
513
|
if (typeof v === "bigint") return v;
|
|
@@ -604,31 +602,12 @@ function addOracleUpdate(tx, config, pool) {
|
|
|
604
602
|
]
|
|
605
603
|
});
|
|
606
604
|
}
|
|
607
|
-
|
|
605
|
+
function refreshStableOracles(tx, config, pools) {
|
|
608
606
|
const stableTypes = STABLE_ASSETS.map((a) => SUPPORTED_ASSETS[a].type);
|
|
609
607
|
const stablePools = pools.filter((p) => {
|
|
610
608
|
const ct = p.suiCoinType || p.coinType || "";
|
|
611
609
|
return stableTypes.some((t) => matchesCoinType(ct, t));
|
|
612
610
|
});
|
|
613
|
-
const feeds = (config.oracle.feeds ?? []).filter(
|
|
614
|
-
(f2) => stablePools.some((p) => p.id === f2.assetId)
|
|
615
|
-
);
|
|
616
|
-
if (feeds.length === 0) return;
|
|
617
|
-
const pythFeedIds = feeds.map((f2) => f2.pythPriceFeedId).filter(Boolean);
|
|
618
|
-
if (pythFeedIds.length > 0 && config.oracle.pythStateId && config.oracle.wormholeStateId) {
|
|
619
|
-
try {
|
|
620
|
-
const connection = new SuiPriceServiceConnection(PYTH_HERMES_URL);
|
|
621
|
-
const priceUpdateData = await connection.getPriceFeedsUpdateData(pythFeedIds);
|
|
622
|
-
const pythClient = new SuiPythClient(
|
|
623
|
-
client,
|
|
624
|
-
config.oracle.pythStateId,
|
|
625
|
-
config.oracle.wormholeStateId
|
|
626
|
-
);
|
|
627
|
-
await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
|
|
628
|
-
} catch (err) {
|
|
629
|
-
console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
611
|
for (const pool of stablePools) {
|
|
633
612
|
addOracleUpdate(tx, config, pool);
|
|
634
613
|
}
|
|
@@ -749,7 +728,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
749
728
|
}
|
|
750
729
|
const tx = new Transaction();
|
|
751
730
|
tx.setSender(address);
|
|
752
|
-
|
|
731
|
+
refreshStableOracles(tx, config, pools);
|
|
753
732
|
const [balance] = tx.moveCall({
|
|
754
733
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
755
734
|
arguments: [
|
|
@@ -794,7 +773,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
794
773
|
});
|
|
795
774
|
return { coin: coin2, effectiveAmount: 0 };
|
|
796
775
|
}
|
|
797
|
-
|
|
776
|
+
refreshStableOracles(tx, config, pools);
|
|
798
777
|
const [balance] = tx.moveCall({
|
|
799
778
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
800
779
|
arguments: [
|
|
@@ -882,7 +861,7 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
882
861
|
]);
|
|
883
862
|
const tx = new Transaction();
|
|
884
863
|
tx.setSender(address);
|
|
885
|
-
|
|
864
|
+
refreshStableOracles(tx, config, pools);
|
|
886
865
|
const [balance] = tx.moveCall({
|
|
887
866
|
target: `${config.package}::incentive_v3::borrow_v2`,
|
|
888
867
|
arguments: [
|