@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/adapters/index.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var transactions = require('@mysten/sui/transactions');
|
|
4
4
|
var bcs = require('@mysten/sui/bcs');
|
|
5
|
-
var pythSuiJs = require('@pythnetwork/pyth-sui-js');
|
|
6
5
|
var aggregatorSdk = require('@cetusprotocol/aggregator-sdk');
|
|
7
6
|
var utils = require('@mysten/sui/utils');
|
|
8
7
|
|
|
@@ -260,7 +259,6 @@ var NAVI_BALANCE_DECIMALS = 9;
|
|
|
260
259
|
var CONFIG_API = "https://open-api.naviprotocol.io/api/navi/config?env=prod";
|
|
261
260
|
var POOLS_API = "https://open-api.naviprotocol.io/api/navi/pools?env=prod";
|
|
262
261
|
var PACKAGE_API = "https://open-api.naviprotocol.io/api/package";
|
|
263
|
-
var PYTH_HERMES_URL = "https://hermes.pyth.network/";
|
|
264
262
|
var packageCache = null;
|
|
265
263
|
function toBigInt(v) {
|
|
266
264
|
if (typeof v === "bigint") return v;
|
|
@@ -355,31 +353,12 @@ function addOracleUpdate(tx, config, pool) {
|
|
|
355
353
|
]
|
|
356
354
|
});
|
|
357
355
|
}
|
|
358
|
-
|
|
356
|
+
function refreshStableOracles(tx, config, pools) {
|
|
359
357
|
const stableTypes = STABLE_ASSETS.map((a) => SUPPORTED_ASSETS[a].type);
|
|
360
358
|
const stablePools = pools.filter((p) => {
|
|
361
359
|
const ct = p.suiCoinType || p.coinType || "";
|
|
362
360
|
return stableTypes.some((t) => matchesCoinType(ct, t));
|
|
363
361
|
});
|
|
364
|
-
const feeds = (config.oracle.feeds ?? []).filter(
|
|
365
|
-
(f2) => stablePools.some((p) => p.id === f2.assetId)
|
|
366
|
-
);
|
|
367
|
-
if (feeds.length === 0) return;
|
|
368
|
-
const pythFeedIds = feeds.map((f2) => f2.pythPriceFeedId).filter(Boolean);
|
|
369
|
-
if (pythFeedIds.length > 0 && config.oracle.pythStateId && config.oracle.wormholeStateId) {
|
|
370
|
-
try {
|
|
371
|
-
const connection = new pythSuiJs.SuiPriceServiceConnection(PYTH_HERMES_URL);
|
|
372
|
-
const priceUpdateData = await connection.getPriceFeedsUpdateData(pythFeedIds);
|
|
373
|
-
const pythClient = new pythSuiJs.SuiPythClient(
|
|
374
|
-
client,
|
|
375
|
-
config.oracle.pythStateId,
|
|
376
|
-
config.oracle.wormholeStateId
|
|
377
|
-
);
|
|
378
|
-
await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
|
|
379
|
-
} catch (err) {
|
|
380
|
-
console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
362
|
for (const pool of stablePools) {
|
|
384
363
|
addOracleUpdate(tx, config, pool);
|
|
385
364
|
}
|
|
@@ -500,7 +479,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
500
479
|
}
|
|
501
480
|
const tx = new transactions.Transaction();
|
|
502
481
|
tx.setSender(address);
|
|
503
|
-
|
|
482
|
+
refreshStableOracles(tx, config, pools);
|
|
504
483
|
const [balance] = tx.moveCall({
|
|
505
484
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
506
485
|
arguments: [
|
|
@@ -545,7 +524,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
545
524
|
});
|
|
546
525
|
return { coin: coin2, effectiveAmount: 0 };
|
|
547
526
|
}
|
|
548
|
-
|
|
527
|
+
refreshStableOracles(tx, config, pools);
|
|
549
528
|
const [balance] = tx.moveCall({
|
|
550
529
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
551
530
|
arguments: [
|
|
@@ -633,7 +612,7 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
633
612
|
]);
|
|
634
613
|
const tx = new transactions.Transaction();
|
|
635
614
|
tx.setSender(address);
|
|
636
|
-
|
|
615
|
+
refreshStableOracles(tx, config, pools);
|
|
637
616
|
const [balance] = tx.moveCall({
|
|
638
617
|
target: `${config.package}::incentive_v3::borrow_v2`,
|
|
639
618
|
arguments: [
|