@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AdapterCapability,
|
|
1
|
+
export { A as AdapterCapability, l as AdapterPositions, m as AdapterTxResult, C as CetusAdapter, p as HealthInfo, L as LendingAdapter, h as LendingRates, N as NaviAdapter, r as ProtocolDescriptor, s as ProtocolRegistry, v as SuilendAdapter, b as SwapAdapter, w as SwapQuote, x as allDescriptors, y as cetusDescriptor, J as naviDescriptor, Q as sentinelDescriptor, X as suilendDescriptor } from '../index-UOQejD-B.cjs';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AdapterCapability,
|
|
1
|
+
export { A as AdapterCapability, l as AdapterPositions, m as AdapterTxResult, C as CetusAdapter, p as HealthInfo, L as LendingAdapter, h as LendingRates, N as NaviAdapter, r as ProtocolDescriptor, s as ProtocolRegistry, v as SuilendAdapter, b as SwapAdapter, w as SwapQuote, x as allDescriptors, y as cetusDescriptor, J as naviDescriptor, Q as sentinelDescriptor, X as suilendDescriptor } from '../index-UOQejD-B.js';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
package/dist/adapters/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { bcs } from '@mysten/sui/bcs';
|
|
3
|
-
import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js';
|
|
4
3
|
import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
|
|
5
4
|
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
6
5
|
|
|
@@ -258,7 +257,6 @@ var NAVI_BALANCE_DECIMALS = 9;
|
|
|
258
257
|
var CONFIG_API = "https://open-api.naviprotocol.io/api/navi/config?env=prod";
|
|
259
258
|
var POOLS_API = "https://open-api.naviprotocol.io/api/navi/pools?env=prod";
|
|
260
259
|
var PACKAGE_API = "https://open-api.naviprotocol.io/api/package";
|
|
261
|
-
var PYTH_HERMES_URL = "https://hermes.pyth.network/";
|
|
262
260
|
var packageCache = null;
|
|
263
261
|
function toBigInt(v) {
|
|
264
262
|
if (typeof v === "bigint") return v;
|
|
@@ -353,31 +351,12 @@ function addOracleUpdate(tx, config, pool) {
|
|
|
353
351
|
]
|
|
354
352
|
});
|
|
355
353
|
}
|
|
356
|
-
|
|
354
|
+
function refreshStableOracles(tx, config, pools) {
|
|
357
355
|
const stableTypes = STABLE_ASSETS.map((a) => SUPPORTED_ASSETS[a].type);
|
|
358
356
|
const stablePools = pools.filter((p) => {
|
|
359
357
|
const ct = p.suiCoinType || p.coinType || "";
|
|
360
358
|
return stableTypes.some((t) => matchesCoinType(ct, t));
|
|
361
359
|
});
|
|
362
|
-
const feeds = (config.oracle.feeds ?? []).filter(
|
|
363
|
-
(f2) => stablePools.some((p) => p.id === f2.assetId)
|
|
364
|
-
);
|
|
365
|
-
if (feeds.length === 0) return;
|
|
366
|
-
const pythFeedIds = feeds.map((f2) => f2.pythPriceFeedId).filter(Boolean);
|
|
367
|
-
if (pythFeedIds.length > 0 && config.oracle.pythStateId && config.oracle.wormholeStateId) {
|
|
368
|
-
try {
|
|
369
|
-
const connection = new SuiPriceServiceConnection(PYTH_HERMES_URL);
|
|
370
|
-
const priceUpdateData = await connection.getPriceFeedsUpdateData(pythFeedIds);
|
|
371
|
-
const pythClient = new SuiPythClient(
|
|
372
|
-
client,
|
|
373
|
-
config.oracle.pythStateId,
|
|
374
|
-
config.oracle.wormholeStateId
|
|
375
|
-
);
|
|
376
|
-
await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
|
|
377
|
-
} catch (err) {
|
|
378
|
-
console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
360
|
for (const pool of stablePools) {
|
|
382
361
|
addOracleUpdate(tx, config, pool);
|
|
383
362
|
}
|
|
@@ -498,7 +477,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
498
477
|
}
|
|
499
478
|
const tx = new Transaction();
|
|
500
479
|
tx.setSender(address);
|
|
501
|
-
|
|
480
|
+
refreshStableOracles(tx, config, pools);
|
|
502
481
|
const [balance] = tx.moveCall({
|
|
503
482
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
504
483
|
arguments: [
|
|
@@ -543,7 +522,7 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
|
|
|
543
522
|
});
|
|
544
523
|
return { coin: coin2, effectiveAmount: 0 };
|
|
545
524
|
}
|
|
546
|
-
|
|
525
|
+
refreshStableOracles(tx, config, pools);
|
|
547
526
|
const [balance] = tx.moveCall({
|
|
548
527
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
549
528
|
arguments: [
|
|
@@ -631,7 +610,7 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
631
610
|
]);
|
|
632
611
|
const tx = new Transaction();
|
|
633
612
|
tx.setSender(address);
|
|
634
|
-
|
|
613
|
+
refreshStableOracles(tx, config, pools);
|
|
635
614
|
const [balance] = tx.moveCall({
|
|
636
615
|
target: `${config.package}::incentive_v3::borrow_v2`,
|
|
637
616
|
arguments: [
|