@naviprotocol/lending 2.0.2 → 2.0.4-beta.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/index.esm.js CHANGED
@@ -1,23 +1,23 @@
1
1
  import { Transaction as N } from "@mysten/sui/transactions";
2
2
  import { bcs as l } from "@mysten/sui/bcs";
3
- import { toHex as Me, fromHex as Ue, normalizeStructTag as K, SUI_CLOCK_OBJECT_ID as Z, fromBase64 as De } from "@mysten/sui/utils";
4
- import Fe from "lodash.camelcase";
3
+ import { toHex as Ue, fromHex as De, normalizeStructTag as K, SUI_CLOCK_OBJECT_ID as Z, fromBase64 as Fe } from "@mysten/sui/utils";
4
+ import Ne from "lodash.camelcase";
5
5
  import p from "bignumber.js";
6
- import { SuiJsonRpcClient as Ne } from "@mysten/sui/jsonRpc";
7
- import { SuiGraphQLClient as Re } from "@mysten/sui/graphql";
8
- import { SuiGrpcClient as ye, GrpcWebFetchTransport as ge } from "@mysten/sui/grpc";
6
+ import { SuiJsonRpcClient as Re } from "@mysten/sui/jsonRpc";
7
+ import { SuiGraphQLClient as Le } from "@mysten/sui/graphql";
8
+ import { SuiGrpcClient as ge, GrpcWebFetchTransport as he } from "@mysten/sui/grpc";
9
9
  const oe = l.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
- input: (e) => Ue(e),
12
- output: (e) => Me(e)
13
- }), qt = l.struct("IncentiveAPYInfo", {
11
+ input: (e) => De(e),
12
+ output: (e) => Ue(e)
13
+ }), zt = l.struct("IncentiveAPYInfo", {
14
14
  /** Asset identifier */
15
15
  asset_id: l.u8(),
16
16
  /** Annual Percentage Yield as a 256-bit integer */
17
17
  apy: l.u256(),
18
18
  /** List of supported coin types for this incentive */
19
19
  coin_types: l.vector(l.string())
20
- }), Le = l.struct("IncentivePoolInfo", {
20
+ }), qe = l.struct("IncentivePoolInfo", {
21
21
  /** Unique pool identifier */
22
22
  pool_id: oe,
23
23
  /** Address holding the incentive funds */
@@ -44,12 +44,12 @@ const oe = l.bytes(32).transform({
44
44
  available: l.u256(),
45
45
  /** Total amount of incentives */
46
46
  total: l.u256()
47
- }), zt = l.struct("IncentivePoolInfoByPhase", {
47
+ }), Gt = l.struct("IncentivePoolInfoByPhase", {
48
48
  /** Phase number */
49
49
  phase: l.u64(),
50
50
  /** List of incentive pools in this phase */
51
- pools: l.vector(Le)
52
- }), Gt = l.struct("OracleInfo", {
51
+ pools: l.vector(qe)
52
+ }), Wt = l.struct("OracleInfo", {
53
53
  /** Oracle identifier */
54
54
  oracle_id: l.u8(),
55
55
  /** Current price as a 256-bit integer */
@@ -58,7 +58,7 @@ const oe = l.bytes(32).transform({
58
58
  decimals: l.u8(),
59
59
  /** Whether the oracle data is valid */
60
60
  valid: l.bool()
61
- }), Wt = l.struct("FlashLoanAssetConfig", {
61
+ }), Ht = l.struct("FlashLoanAssetConfig", {
62
62
  /** Unique identifier for the flash loan asset */
63
63
  id: l.string(),
64
64
  /** Asset identifier */
@@ -75,7 +75,7 @@ const oe = l.bytes(32).transform({
75
75
  max: l.u64(),
76
76
  /** Minimum flash loan amount */
77
77
  min: l.u64()
78
- }), qe = l.struct("ReserveDataInfo", {
78
+ }), ze = l.struct("ReserveDataInfo", {
79
79
  /** Reserve identifier */
80
80
  id: l.u8(),
81
81
  /** Oracle identifier for price feeds */
@@ -122,26 +122,26 @@ const oe = l.bytes(32).transform({
122
122
  liquidation_bonus: l.u256(),
123
123
  /** Liquidation threshold */
124
124
  liquidation_threshold: l.u256()
125
- }), ze = l.struct("UserStateInfo", {
125
+ }), Ge = l.struct("UserStateInfo", {
126
126
  /** Asset identifier */
127
127
  asset_id: l.u8(),
128
128
  /** User's current borrow balance */
129
129
  borrow_balance: l.u256(),
130
130
  /** User's current supply balance */
131
131
  supply_balance: l.u256()
132
- }), Ge = "2.0.2", O = {
133
- version: Ge
134
- }, We = O.version, He = () => {
132
+ }), We = "2.0.4-beta.0", E = {
133
+ version: We
134
+ }, He = E.version, Je = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node) {
136
136
  const e = process.version;
137
137
  return `Node.js ${e.startsWith("v") ? e.substring(1) : e}`;
138
138
  }
139
139
  return "Node/Unknown";
140
- }, Je = () => {
140
+ }, Ke = () => {
141
141
  let e = "";
142
- return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${We} (${He()})`), e;
143
- }, ae = Je(), he = "0x2::sui::SUI";
144
- class Ke extends Error {
142
+ return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${He} (${Je()})`), e;
143
+ }, ae = Ke(), we = "0x2::sui::SUI";
144
+ class Qe extends Error {
145
145
  constructor(t) {
146
146
  super(
147
147
  `NAVI Sui SDK capability "${t}" requires an explicit graphql client; no public GraphQL fallback is configured`
@@ -151,22 +151,22 @@ class Ke extends Error {
151
151
  function X(e) {
152
152
  return e == null ? void 0 : String(e);
153
153
  }
154
- function Qe(e, t) {
154
+ function Ye(e, t) {
155
155
  return (BigInt(e) + BigInt(t)).toString();
156
156
  }
157
- function Ye(e, t) {
157
+ function Ze(e, t) {
158
158
  return (BigInt(e) - BigInt(t)).toString();
159
159
  }
160
- function we(e) {
160
+ function be(e) {
161
161
  const t = e.core;
162
162
  if (typeof t?.getBalance != "function" || typeof t?.listBalances != "function")
163
163
  throw new Error("NAVI Sui balance helpers require a v2 Core API client");
164
164
  return t;
165
165
  }
166
- function be(e, t = he) {
166
+ function ve(e, t = we) {
167
167
  const r = X(e.addressBalance ?? e.fundsInAddressBalance) ?? "0";
168
168
  let o = X(e.balance ?? e.totalBalance), n = X(e.coinBalance);
169
- return !n && o && (n = Ye(o, r)), !o && n && (o = Qe(n, r)), {
169
+ return !n && o && (n = Ze(o, r)), !o && n && (o = Ye(n, r)), {
170
170
  coinType: K(e.coinType ?? t),
171
171
  totalBalance: o ?? "0",
172
172
  coinBalance: n ?? "0",
@@ -174,77 +174,77 @@ function be(e, t = he) {
174
174
  ...e.coinObjectCount === null || e.coinObjectCount === void 0 ? {} : { coinObjectCount: e.coinObjectCount }
175
175
  };
176
176
  }
177
- function Ht(e, t = he) {
177
+ function Jt(e, t = we) {
178
178
  const r = K(t);
179
179
  return e.filter((o) => K(o.coinType) === r).reduce((o, n) => o + BigInt(n.balance), 0n).toString();
180
180
  }
181
- async function Jt(e, t) {
182
- const r = await we(e).getBalance(t), o = r.balance;
183
- return be((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
184
- }
185
181
  async function Kt(e, t) {
186
- const r = await we(e).listBalances(t), { balances: o = [] } = r;
182
+ const r = await be(e).getBalance(t), o = r.balance;
183
+ return ve((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
184
+ }
185
+ async function Qt(e, t) {
186
+ const r = await be(e).listBalances(t), { balances: o = [] } = r;
187
187
  return {
188
- balances: o.map((n) => be(n)),
188
+ balances: o.map((n) => ve(n)),
189
189
  nextCursor: r.nextCursor ?? r.cursor ?? null
190
190
  };
191
191
  }
192
- function Ze(e, t) {
192
+ function Xe(e, t) {
193
193
  if ("client" in t)
194
194
  return t.client;
195
- const r = new ge({
195
+ const r = new he({
196
196
  baseUrl: t.url,
197
197
  meta: t.headers,
198
198
  fetchInit: t.fetchInit,
199
199
  fetch: t.fetch
200
200
  });
201
- return new ye({
201
+ return new ge({
202
202
  network: e,
203
203
  transport: r
204
204
  });
205
205
  }
206
- function Xe(e, t) {
207
- return "client" in t ? t.client : new Re({
206
+ function xe(e, t) {
207
+ return "client" in t ? t.client : new Le({
208
208
  network: e,
209
209
  url: t.url,
210
210
  headers: t.headers,
211
211
  fetch: t.fetch
212
212
  });
213
213
  }
214
- function ve(e, t) {
215
- return "client" in t ? t.client : new Ne({
214
+ function Ce(e, t) {
215
+ return "client" in t ? t.client : new Re({
216
216
  network: e,
217
217
  url: t.url
218
218
  });
219
219
  }
220
- function xe(e) {
221
- const t = Ze(e.network, e.grpc);
220
+ function et(e) {
221
+ const t = Xe(e.network, e.grpc);
222
222
  return {
223
223
  network: e.network,
224
224
  coreClient: t,
225
225
  grpc: t,
226
- graphql: e.graphql ? Xe(e.network, e.graphql) : void 0,
227
- legacyJsonRpc: e.legacyJsonRpc ? ve(e.network, e.legacyJsonRpc) : void 0,
226
+ graphql: e.graphql ? xe(e.network, e.graphql) : void 0,
227
+ legacyJsonRpc: e.legacyJsonRpc ? Ce(e.network, e.legacyJsonRpc) : void 0,
228
228
  services: e.services
229
229
  };
230
230
  }
231
- function Qt(e, t) {
231
+ function Yt(e, t) {
232
232
  if (!e.graphql)
233
- throw new Ke(t);
233
+ throw new Qe(t);
234
234
  return e.graphql;
235
235
  }
236
- const et = "https://fullnode.mainnet.sui.io:443";
236
+ const tt = "https://fullnode.mainnet.sui.io:443";
237
237
  let x;
238
- function tt() {
239
- return x || (x = new ye({
238
+ function rt() {
239
+ return x || (x = new ge({
240
240
  network: "mainnet",
241
- transport: new ge({ baseUrl: et })
241
+ transport: new he({ baseUrl: tt })
242
242
  })), x;
243
243
  }
244
- function rt(e, t = "mainnet") {
245
- return e ? typeof e == "string" ? ve(t, { url: e }) : xe(e) : tt();
244
+ function nt(e, t = "mainnet") {
245
+ return e ? typeof e == "string" ? Ce(t, { url: e }) : et(e) : rt();
246
246
  }
247
- const nt = 16 * 1024;
247
+ const ot = 16 * 1024;
248
248
  function re(e) {
249
249
  return e.replace(/^0x/i, "");
250
250
  }
@@ -254,12 +254,12 @@ function ie(e) {
254
254
  r[o] = parseInt(t.slice(o * 2, o * 2 + 2), 16);
255
255
  return r;
256
256
  }
257
- function ot(e, t) {
257
+ function at(e, t) {
258
258
  return (e[t] << 8) + e[t + 1];
259
259
  }
260
260
  function ce(e) {
261
261
  return l.vector(l.U8).serialize(Array.from(e), {
262
- maxSize: nt
262
+ maxSize: ot
263
263
  });
264
264
  }
265
265
  function se(e, t) {
@@ -268,17 +268,17 @@ function se(e, t) {
268
268
  bcs: t
269
269
  };
270
270
  }
271
- function at(e) {
271
+ function it(e) {
272
272
  return l.vector(l.U8).serialize(Array.from(new TextEncoder().encode(e))).toBytes();
273
273
  }
274
- function it(e) {
274
+ function ct(e) {
275
275
  return l.struct("PriceIdentifier", {
276
276
  bytes: l.vector(l.U8)
277
277
  }).serialize({
278
278
  bytes: Array.from(e)
279
279
  }).toBytes();
280
280
  }
281
- function ct(e) {
281
+ function st(e) {
282
282
  const t = [];
283
283
  let r = 0, o = 0;
284
284
  for (let n = 0; n < e.length; n += 1) {
@@ -287,19 +287,19 @@ function ct(e) {
287
287
  }
288
288
  return t.push(e.slice(o).trim()), t;
289
289
  }
290
- function st(e) {
290
+ function ut(e) {
291
291
  const r = e.indexOf("::table::Table"), o = e.indexOf("<", r), n = e.lastIndexOf(">"), a = "::price_identifier::PriceIdentifier";
292
292
  if (r < 0 || o < 0 || n <= o)
293
293
  throw new Error(`Unexpected Pyth price table type: ${e}`);
294
- const [c, i] = ct(e.slice(o + 1, n));
294
+ const [c, i] = st(e.slice(o + 1, n));
295
295
  if (!c?.endsWith(a) || !i?.endsWith("::object::ID"))
296
296
  throw new Error(`Unexpected Pyth price table type arguments: ${e}`);
297
297
  return c.slice(0, -a.length);
298
298
  }
299
- function ut(e) {
299
+ function lt(e) {
300
300
  return Uint8Array.from(atob(e), (t) => t.charCodeAt(0));
301
301
  }
302
- class Ce {
302
+ class je {
303
303
  constructor(t, r) {
304
304
  this.endpoint = t.replace(/\/$/, ""), this.timeout = r?.timeout ?? 1e4;
305
305
  }
@@ -327,7 +327,7 @@ class Ce {
327
327
  throw new Error(`Unsupported Hermes price update encoding: ${o}`);
328
328
  if (n.length === 0)
329
329
  throw new Error("Hermes price update response did not include binary update data");
330
- return n.map(ut);
330
+ return n.map(lt);
331
331
  }
332
332
  async get(t, r, o) {
333
333
  const n = new AbortController(), a = setTimeout(() => n.abort(), this.timeout), c = new URL(`${this.endpoint}${t}`);
@@ -347,13 +347,13 @@ class Ce {
347
347
  }
348
348
  }
349
349
  }
350
- class lt {
350
+ class dt {
351
351
  constructor(t, r, o) {
352
352
  this.provider = t, this.pythStateId = r, this.wormholeStateId = o, this.priceFeedObjectIdCache = /* @__PURE__ */ new Map();
353
353
  }
354
354
  getCoreProvider() {
355
355
  const t = this.provider.core;
356
- return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" ? t : null;
356
+ return t && typeof t.getObject == "function" && typeof t.getDynamicObjectField == "function" && typeof t.getDynamicField == "function" ? t : null;
357
357
  }
358
358
  async getMoveObjectJson(t) {
359
359
  const r = this.getCoreProvider();
@@ -500,22 +500,31 @@ class lt {
500
500
  async getPriceFeedObjectId(t) {
501
501
  const r = re(t);
502
502
  if (!this.priceFeedObjectIdCache.has(r)) {
503
- const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = this.getCoreProvider() ? se(
504
- `${n}::price_identifier::PriceIdentifier`,
505
- it(ie(r))
506
- ) : {
507
- type: `${n}::price_identifier::PriceIdentifier`,
508
- value: {
509
- bytes: Array.from(ie(r))
510
- }
511
- }, c = await this.getDynamicMoveObjectJson(o, a);
512
- c?.fields ? this.priceFeedObjectIdCache.set(r, c.fields.value) : this.priceFeedObjectIdCache.set(r, void 0);
503
+ const { id: o, fieldType: n } = await this.getPriceTableInfo(), a = `${n}::price_identifier::PriceIdentifier`, c = this.getCoreProvider();
504
+ if (c) {
505
+ const { dynamicField: i } = await c.getDynamicField({
506
+ parentId: o,
507
+ name: se(a, ct(ie(r)))
508
+ }), s = i?.value?.bcs;
509
+ this.priceFeedObjectIdCache.set(
510
+ r,
511
+ s && s.length === 32 ? l.Address.parse(Uint8Array.from(s)) : void 0
512
+ );
513
+ } else {
514
+ const i = await this.getDynamicMoveObjectJson(o, {
515
+ type: a,
516
+ value: {
517
+ bytes: Array.from(ie(r))
518
+ }
519
+ });
520
+ i?.fields ? this.priceFeedObjectIdCache.set(r, i.fields.value) : this.priceFeedObjectIdCache.set(r, void 0);
521
+ }
513
522
  }
514
523
  return this.priceFeedObjectIdCache.get(r);
515
524
  }
516
525
  async getPriceTableInfo() {
517
526
  if (!this.priceTableInfo) {
518
- const t = this.getCoreProvider() ? se("vector<u8>", at("price_info")) : {
527
+ const t = this.getCoreProvider() ? se("vector<u8>", it("price_info")) : {
519
528
  type: "vector<u8>",
520
529
  value: "price_info"
521
530
  }, r = await this.getDynamicMoveObjectJson(this.pythStateId, t);
@@ -523,22 +532,22 @@ class lt {
523
532
  throw new Error("Price Table not found, contract may not be initialized");
524
533
  this.priceTableInfo = {
525
534
  id: r.objectId,
526
- fieldType: st(r.type)
535
+ fieldType: ut(r.type)
527
536
  };
528
537
  }
529
538
  return this.priceTableInfo;
530
539
  }
531
540
  extractVaaBytesFromAccumulatorMessage(t) {
532
- const o = 7 + t[6] + 1, n = ot(t, o), a = o + 2;
541
+ const o = 7 + t[6] + 1, n = at(t, o), a = o + 2;
533
542
  return t.subarray(a, a + n);
534
543
  }
535
544
  }
536
- const dt = "https://open-api.naviprotocol.io/api";
537
- let J = {}, je = 0;
538
- function pt(e) {
545
+ const pt = "https://open-api.naviprotocol.io/api";
546
+ let J = {}, ke = 0;
547
+ function mt(e) {
539
548
  return e.replace(/\/+$/, "");
540
549
  }
541
- function Yt(e) {
550
+ function Zt(e) {
542
551
  J = {
543
552
  ...J,
544
553
  ...e,
@@ -546,23 +555,23 @@ function Yt(e) {
546
555
  ...J.services,
547
556
  ...e.services
548
557
  }
549
- }, je += 1;
558
+ }, ke += 1;
550
559
  }
551
560
  function ue() {
552
- return je;
561
+ return ke;
553
562
  }
554
- function E(e) {
563
+ function O(e) {
555
564
  const t = e?.services?.naviOpenApi ?? J.services?.naviOpenApi;
556
565
  return {
557
- baseUrl: pt(t?.baseUrl ?? dt),
566
+ baseUrl: mt(t?.baseUrl ?? pt),
558
567
  headers: t?.headers
559
568
  };
560
569
  }
561
570
  function M(e, t) {
562
- const r = E(t), o = e.startsWith("/") ? e : `/${e}`;
571
+ const r = O(t), o = e.startsWith("/") ? e : `/${e}`;
563
572
  return `${r.baseUrl}${o}`;
564
573
  }
565
- function mt(e) {
574
+ function ft(e) {
566
575
  if (e instanceof Headers) {
567
576
  const t = {};
568
577
  return e.forEach((r, o) => {
@@ -573,15 +582,15 @@ function mt(e) {
573
582
  }
574
583
  function U(e, t) {
575
584
  return {
576
- ...mt(e),
585
+ ...ft(e),
577
586
  ...t?.headers ?? {}
578
587
  };
579
588
  }
580
- const V = rt();
589
+ const V = nt();
581
590
  function le(e) {
582
- return e ? e instanceof Uint8Array ? Array.from(e) : Array.isArray(e) ? e : Array.from(De(e)) : [];
591
+ return e ? e instanceof Uint8Array ? Array.from(e) : Array.isArray(e) ? e : Array.from(Fe(e)) : [];
583
592
  }
584
- function ft(e) {
593
+ function yt(e) {
585
594
  const t = e?.commandResults ?? [], r = e?.Transaction ?? e?.FailedTransaction ?? {}, o = r.effects?.errors?.[0] ?? r.effects?.status?.error ?? r.status?.error ?? r.status?.errors?.[0];
586
595
  return o && console.warn("[lending] devInspect(core simulate) returned error:", o), {
587
596
  effects: r.effects,
@@ -612,7 +621,7 @@ async function q(e, t) {
612
621
  commandResults: !0
613
622
  }
614
623
  });
615
- return ft(n);
624
+ return yt(n);
616
625
  }
617
626
  function Ie(e) {
618
627
  return {
@@ -622,7 +631,7 @@ function Ie(e) {
622
631
  objectBcs: !!e?.showBcs
623
632
  };
624
633
  }
625
- function ke(e) {
634
+ function _e(e) {
626
635
  return !e || e instanceof Error ? {
627
636
  error: e instanceof Error ? { code: "notFound", error: e.message } : void 0
628
637
  } : {
@@ -642,7 +651,7 @@ function ke(e) {
642
651
  }
643
652
  };
644
653
  }
645
- async function yt(e, t) {
654
+ async function gt(e, t) {
646
655
  const r = e?.core;
647
656
  if (typeof r?.getObject != "function")
648
657
  throw new Error("getSuiObject requires a Sui v2 Core-capable client");
@@ -650,9 +659,9 @@ async function yt(e, t) {
650
659
  objectId: t.id,
651
660
  include: Ie(t.options)
652
661
  });
653
- return ke(o);
662
+ return _e(o);
654
663
  }
655
- async function gt(e, t) {
664
+ async function ht(e, t) {
656
665
  const r = e?.core;
657
666
  if (typeof r?.getObjects != "function")
658
667
  throw new Error("multiGetSuiObjects requires a Sui v2 Core-capable client");
@@ -660,9 +669,9 @@ async function gt(e, t) {
660
669
  objectIds: t.ids,
661
670
  include: Ie(t.options)
662
671
  });
663
- return o.map(ke);
672
+ return o.map(_e);
664
673
  }
665
- function _e(e) {
674
+ function Te(e) {
666
675
  const t = [];
667
676
  let r = !1;
668
677
  return e.forEach((o, n) => {
@@ -679,7 +688,7 @@ function _e(e) {
679
688
  function A(e) {
680
689
  const t = {};
681
690
  return (...r) => {
682
- const o = _e(r);
691
+ const o = Te(r);
683
692
  return t[o] || (t[o] = e(...r).finally(() => {
684
693
  delete t[o];
685
694
  })), t[o];
@@ -688,7 +697,7 @@ function A(e) {
688
697
  function $(e) {
689
698
  let t = {};
690
699
  return (...r) => {
691
- const o = r[r.length - 1], n = _e(r), a = t[n];
700
+ const o = r[r.length - 1], n = Te(r), a = t[n];
692
701
  return !o?.disableCache && typeof a?.data < "u" && (typeof o?.cacheTime > "u" || o.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...r).then((c) => (t[n] = {
693
702
  data: c,
694
703
  cacheAt: Date.now()
@@ -699,7 +708,7 @@ function ee(e) {
699
708
  return Array.isArray(e) ? e.map((t) => ee(t)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
700
709
  (t, r) => ({
701
710
  ...t,
702
- [Fe(r)]: ee(e[r])
711
+ [Ne(r)]: ee(e[r])
703
712
  }),
704
713
  {}
705
714
  ) : e;
@@ -709,7 +718,7 @@ function h(e, t) {
709
718
  throw new Error("Transaction value is required");
710
719
  return typeof e == "object" ? e : t(e);
711
720
  }
712
- function ht(e, t) {
721
+ function wt(e, t) {
713
722
  return typeof t == "string" ? e.object(t) : typeof t == "object" && t.$kind ? t : e.object(t.contract.pool);
714
723
  }
715
724
  function Q(e, t, r) {
@@ -723,16 +732,16 @@ function Q(e, t, r) {
723
732
  function C(e) {
724
733
  return K(e);
725
734
  }
726
- function Te(e) {
735
+ function Be(e) {
727
736
  const t = (e || 0) / Math.pow(10, 27);
728
737
  return t > Math.pow(10, 5) ? 1 / 0 : t;
729
738
  }
730
- new Ce("https://hermes.pyth.network", {
739
+ new je("https://hermes.pyth.network", {
731
740
  timeout: 2e4
732
741
  });
733
- const wt = 27, de = (e, t) => {
742
+ const bt = 27, de = (e, t) => {
734
743
  if (!Number(e) || !Number(t)) return new p(0);
735
- const r = new p(1).shiftedBy(1 * wt), o = r.multipliedBy(new p(0.5));
744
+ const r = new p(1).shiftedBy(1 * bt), o = r.multipliedBy(new p(0.5));
736
745
  return new p(e).multipliedBy(new p(t)).plus(o).dividedBy(r).integerValue(p.ROUND_DOWN);
737
746
  }, D = ae ? {
738
747
  "User-Agent": ae
@@ -763,7 +772,7 @@ function H(e, t) {
763
772
  isEMode: !0
764
773
  };
765
774
  }
766
- function bt(e) {
775
+ function vt(e) {
767
776
  const [t, r] = e.split("-");
768
777
  return !t || !r ? null : {
769
778
  marketKey: t,
@@ -777,8 +786,8 @@ var z = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] =
777
786
  const G = $(
778
787
  A(
779
788
  async (e) => {
780
- const t = (e?.markets || [F.main]).map((a) => _(a)), r = E(e), o = M(
781
- `/navi/pools?env=${e?.env || "prod"}&sdk=${O.version}&market=${t.map(
789
+ const t = (e?.markets || [F.main]).map((a) => _(a)), r = O(e), o = M(
790
+ `/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${t.map(
782
791
  (a) => a.key
783
792
  )}`,
784
793
  e
@@ -787,9 +796,9 @@ const G = $(
787
796
  );
788
797
  return n.data.forEach((a) => {
789
798
  const i = n.meta.emodes.filter((b) => {
790
- const I = _(b.marketId);
791
- return a.market === I.key && b.isActive;
792
- }).filter((b) => !!b.assets.find((I) => I.assetId === a.id));
799
+ const k = _(b.marketId);
800
+ return a.market === k.key && b.isActive;
801
+ }).filter((b) => !!b.assets.find((k) => k.assetId === a.id));
793
802
  a.emodes = i;
794
803
  const s = p(a.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), u = p(a.borrowedAmount).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), m = p(s).multipliedBy(a.oracle.price).toString(), w = p(u).multipliedBy(a.oracle.price).toString(), y = p(a.supplyCapCeiling).shiftedBy(-27).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), g = p.max(
795
804
  p(a.borrowedAmount),
@@ -803,7 +812,7 @@ const G = $(
803
812
  async function S(e, t) {
804
813
  let r = t?.market;
805
814
  if (typeof e == "string") {
806
- const a = bt(e);
815
+ const a = vt(e);
807
816
  a && (r = a.marketKey, e = a.poolId);
808
817
  }
809
818
  const o = await G({
@@ -818,24 +827,24 @@ async function S(e, t) {
818
827
  throw new Error("Pool not found");
819
828
  return n.isDeprecated && console.log(`The lending pool for coinType ${n.suiCoinType} is going to be deprecated.`), n;
820
829
  }
821
- const Zt = $(
830
+ const Xt = $(
822
831
  A(async (e) => {
823
- const t = E(e), r = M(`/navi/stats?sdk=${O.version}`, e);
832
+ const t = O(e), r = M(`/navi/stats?sdk=${E.version}`, e);
824
833
  return (await fetch(r, {
825
834
  headers: U(D, t)
826
835
  }).then((n) => n.json())).data;
827
836
  })
828
- ), Xt = $(
837
+ ), xt = $(
829
838
  A(
830
839
  async (e) => {
831
- const t = E(e), r = M(`/navi/fee?sdk=${O.version}`, e);
840
+ const t = O(e), r = M(`/navi/fee?sdk=${E.version}`, e);
832
841
  return await fetch(r, {
833
842
  headers: U(D, t)
834
843
  }).then((n) => n.json());
835
844
  }
836
845
  )
837
846
  );
838
- async function vt(e, t, r, o) {
847
+ async function Ct(e, t, r, o) {
839
848
  const n = await j({
840
849
  ...o,
841
850
  cacheTime: v
@@ -883,7 +892,7 @@ async function vt(e, t, r, o) {
883
892
  arguments: [e.object(a.contract.pool), e.object("0x05")]
884
893
  }), e;
885
894
  }
886
- async function xt(e, t, r, o) {
895
+ async function er(e, t, r, o) {
887
896
  const n = await j({
888
897
  ...o,
889
898
  cacheTime: v
@@ -966,7 +975,7 @@ async function xt(e, t, r, o) {
966
975
  typeArguments: [a.suiCoinType]
967
976
  });
968
977
  }
969
- async function er(e, t, r, o) {
978
+ async function tr(e, t, r, o) {
970
979
  const n = await j({
971
980
  ...o,
972
981
  cacheTime: v
@@ -1052,7 +1061,7 @@ async function er(e, t, r, o) {
1052
1061
  typeArguments: [a.suiCoinType]
1053
1062
  });
1054
1063
  }
1055
- async function tr(e, t, r, o) {
1064
+ async function rr(e, t, r, o) {
1056
1065
  const n = await j({
1057
1066
  ...o,
1058
1067
  cacheTime: v
@@ -1105,7 +1114,7 @@ async function tr(e, t, r, o) {
1105
1114
  typeArguments: [a.suiCoinType]
1106
1115
  }), e;
1107
1116
  }
1108
- const rr = $(
1117
+ const nr = $(
1109
1118
  A(
1110
1119
  async (e) => {
1111
1120
  const t = await j({
@@ -1135,7 +1144,7 @@ const rr = $(
1135
1144
  a
1136
1145
  );
1137
1146
  }
1138
- const n = (await yt(r, {
1147
+ const n = (await gt(r, {
1139
1148
  id: t.incentiveV3,
1140
1149
  options: { showType: !0, showOwner: !0, showContent: !0 }
1141
1150
  })).data.content.fields.borrow_fee_rate;
@@ -1164,7 +1173,7 @@ const rr = $(
1164
1173
  name: "Sui Eco Market"
1165
1174
  }
1166
1175
  };
1167
- class Ct {
1176
+ class jt {
1168
1177
  constructor(t, r) {
1169
1178
  this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
1170
1179
  marketTotalSupplyValue: "0",
@@ -1232,7 +1241,7 @@ const _ = (e) => {
1232
1241
  if (!r)
1233
1242
  throw new Error("Market not found");
1234
1243
  return r;
1235
- }, jt = $(
1244
+ }, kt = $(
1236
1245
  A(
1237
1246
  async (e, t) => {
1238
1247
  const r = await G({
@@ -1242,19 +1251,19 @@ const _ = (e) => {
1242
1251
  });
1243
1252
  return e.map((o) => {
1244
1253
  const n = _(o), a = r.filter((c) => c.market === n.key);
1245
- return new Ct(o, a);
1254
+ return new jt(o, a);
1246
1255
  });
1247
1256
  }
1248
1257
  )
1249
- ), nr = $(
1258
+ ), or = $(
1250
1259
  A(
1251
- async (e, t) => (await jt([e], t))[0]
1260
+ async (e, t) => (await kt([e], t))[0]
1252
1261
  )
1253
1262
  ), j = $(
1254
1263
  A(
1255
1264
  async (e) => {
1256
- const t = _(e?.market || R), r = E(e), o = M(
1257
- `/navi/config?env=${e?.env || "prod"}&sdk=${O.version}&market=${t.key}`,
1265
+ const t = _(e?.market || R), r = O(e), o = M(
1266
+ `/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${t.key}`,
1258
1267
  e
1259
1268
  );
1260
1269
  return (await fetch(o, {
@@ -1273,7 +1282,7 @@ async function It(e, t) {
1273
1282
  arguments: []
1274
1283
  });
1275
1284
  }
1276
- async function kt(e, t, r) {
1285
+ async function _t(e, t, r) {
1277
1286
  const o = await j({
1278
1287
  cacheTime: v,
1279
1288
  ...r
@@ -1283,7 +1292,7 @@ async function kt(e, t, r) {
1283
1292
  arguments: [t]
1284
1293
  });
1285
1294
  }
1286
- async function _t(e, t, r) {
1295
+ async function Tt(e, t, r) {
1287
1296
  const o = await j({
1288
1297
  ...r,
1289
1298
  cacheTime: v
@@ -1300,7 +1309,7 @@ async function _t(e, t, r) {
1300
1309
  arguments: [e.object(o.storage), h(t, e.pure.u64)]
1301
1310
  }), e;
1302
1311
  }
1303
- async function or(e, t) {
1312
+ async function ar(e, t) {
1304
1313
  const r = await j({
1305
1314
  ...t,
1306
1315
  cacheTime: v
@@ -1313,16 +1322,16 @@ async function or(e, t) {
1313
1322
  arguments: [e.object(r.storage)]
1314
1323
  }), e;
1315
1324
  }
1316
- async function ar(e, t, r) {
1325
+ async function ir(e, t, r) {
1317
1326
  const o = await j({
1318
1327
  cacheTime: v,
1319
1328
  ...r
1320
1329
  }), n = await It(e, r);
1321
- await _t(e, t, {
1330
+ await Tt(e, t, {
1322
1331
  ...r,
1323
1332
  accountCap: n
1324
1333
  });
1325
- const a = await _(r?.market || R), c = await kt(e, n, r);
1334
+ const a = await _(r?.market || R), c = await _t(e, n, r);
1326
1335
  return e.moveCall({
1327
1336
  target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
1328
1337
  arguments: [
@@ -1333,7 +1342,7 @@ async function ar(e, t, r) {
1333
1342
  ]
1334
1343
  }), n;
1335
1344
  }
1336
- const Be = $(
1345
+ const Pe = $(
1337
1346
  A(
1338
1347
  async (e, t) => {
1339
1348
  const r = await j({
@@ -1356,21 +1365,21 @@ const Be = $(
1356
1365
  }
1357
1366
  )
1358
1367
  );
1359
- function ir(e) {
1368
+ function cr(e) {
1360
1369
  return `${_(e.marketId).key}-${e.emodeId}`;
1361
1370
  }
1362
- function Tt(e, t) {
1371
+ function Bt(e, t) {
1363
1372
  return e.coinType ? e.coinType : t || (typeof e.type == "string" ? e.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
1364
1373
  }
1365
1374
  function me(e, t) {
1366
- const r = Tt(e, t), o = e.coinObjectId ?? e.objectId;
1375
+ const r = Bt(e, t), o = e.coinObjectId ?? e.objectId;
1367
1376
  return !r || !o || e.balance === void 0 || e.balance === null ? null : {
1368
1377
  ...e,
1369
1378
  coinType: C(r),
1370
1379
  coinObjectId: o
1371
1380
  };
1372
1381
  }
1373
- function cr(e, t, r) {
1382
+ function sr(e, t, r) {
1374
1383
  const o = typeof r?.balance == "number", n = o ? r.balance : 0;
1375
1384
  let a = 0;
1376
1385
  const c = [];
@@ -1389,7 +1398,7 @@ function cr(e, t, r) {
1389
1398
  );
1390
1399
  return C(i) === C("0x2::sui::SUI") && r?.useGasCoin ? o ? e.splitCoins(e.gas, [e.pure.u64(n)]) : e.gas : (c.length === 1 ? e.object(c[0]) : e.mergeCoins(c[0], c.slice(1)), o ? e.splitCoins(c[0], [e.pure.u64(n)]) : c[0]);
1391
1400
  }
1392
- async function Pe(e, t, r, o, n, a, c) {
1401
+ async function Ae(e, t, r, o, n, a, c) {
1393
1402
  const i = await j({
1394
1403
  ...c,
1395
1404
  cacheTime: v
@@ -1400,7 +1409,7 @@ async function Pe(e, t, r, o, n, a, c) {
1400
1409
  e.object("0x06"),
1401
1410
  e.object(i.storage),
1402
1411
  e.object(i.oracle.priceOracle),
1403
- ht(e, s),
1412
+ wt(e, s),
1404
1413
  h(t, e.pure.address),
1405
1414
  h(s.id, e.pure.u8),
1406
1415
  h(o, e.pure.u64),
@@ -1410,10 +1419,10 @@ async function Pe(e, t, r, o, n, a, c) {
1410
1419
  typeArguments: [s.suiCoinType]
1411
1420
  });
1412
1421
  }
1413
- async function Bt(e, t, r) {
1414
- return Pe(e, t, 0, 0, 0, !1, r);
1422
+ async function Pt(e, t, r) {
1423
+ return Ae(e, t, 0, 0, 0, !1, r);
1415
1424
  }
1416
- async function Ae(e, t, r) {
1425
+ async function Se(e, t, r) {
1417
1426
  const o = new N(), n = r?.client ?? V, a = await G({
1418
1427
  ...r,
1419
1428
  markets: Object.values(F)
@@ -1446,13 +1455,13 @@ async function Ae(e, t, r) {
1446
1455
  })).results || [], w = {};
1447
1456
  s.forEach((d, f) => {
1448
1457
  try {
1449
- const b = m[f]?.returnValues?.map((T) => l.vector(qe).parse(Uint8Array.from(T[0])))[0] || [], I = {};
1458
+ const b = m[f]?.returnValues?.map((T) => l.vector(ze).parse(Uint8Array.from(T[0])))[0] || [], k = {};
1450
1459
  for (const T of b)
1451
- I[T.id] = {
1460
+ k[T.id] = {
1452
1461
  supplyIndex: T.supply_index,
1453
1462
  borrowIndex: T.borrow_index
1454
1463
  };
1455
- w[d.key] = I;
1464
+ w[d.key] = k;
1456
1465
  } catch (b) {
1457
1466
  console.warn(
1458
1467
  `[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
@@ -1460,46 +1469,46 @@ async function Ae(e, t, r) {
1460
1469
  );
1461
1470
  }
1462
1471
  });
1463
- const y = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(ze).parse(Uint8Array.from(f[0])))[0] || []), g = [];
1472
+ const y = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(Ge).parse(Uint8Array.from(f[0])))[0] || []), g = [];
1464
1473
  return y.forEach((d, f) => {
1465
- const b = t[f], I = _(b.market), T = w[I.key] || {};
1466
- d.forEach((k) => {
1467
- if (k.supply_balance === "0" && k.borrow_balance === "0" && (b.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
1474
+ const b = t[f], k = _(b.market), T = w[k.key] || {};
1475
+ d.forEach((I) => {
1476
+ if (I.supply_balance === "0" && I.borrow_balance === "0" && (b.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
1468
1477
  return;
1469
- const B = c[`${I.key}-${k.asset_id}`];
1478
+ const B = c[`${k.key}-${I.asset_id}`];
1470
1479
  if (!B)
1471
1480
  return;
1472
- const W = T[k.asset_id], Y = W?.supplyIndex ?? B.currentSupplyIndex, Oe = W?.borrowIndex ?? B.currentBorrowIndex, Ee = de(k.supply_balance, Y).toString(), Ve = de(k.borrow_balance, Oe).toString();
1481
+ const W = T[I.asset_id], Y = W?.supplyIndex ?? B.currentSupplyIndex, Oe = W?.borrowIndex ?? B.currentBorrowIndex, Ve = de(I.supply_balance, Y).toString(), Me = de(I.borrow_balance, Oe).toString();
1473
1482
  g.push({
1474
- supplyBalance: Ee,
1475
- borrowBalance: Ve,
1476
- assetId: k.asset_id,
1477
- market: I.key,
1483
+ supplyBalance: Ve,
1484
+ borrowBalance: Me,
1485
+ assetId: I.asset_id,
1486
+ market: k.key,
1478
1487
  pool: B,
1479
1488
  emodeId: b.emodeId
1480
1489
  });
1481
1490
  });
1482
1491
  }), g;
1483
1492
  }
1484
- const sr = $(
1493
+ const ur = $(
1485
1494
  async (e, t) => {
1486
1495
  const o = (t?.markets || Object.keys(F)).map((n) => _(n)).map((n) => ({
1487
1496
  address: e,
1488
1497
  market: n.key
1489
1498
  }));
1490
- return await Ae(e, o, t);
1499
+ return await Se(e, o, t);
1491
1500
  }
1492
1501
  );
1493
- async function ur(e, t) {
1502
+ async function lr(e, t) {
1494
1503
  const r = t?.client ?? V, o = new N();
1495
- await Bt(o, e, t);
1504
+ await Pt(o, e, t);
1496
1505
  const n = await q(r, {
1497
1506
  transactionBlock: o,
1498
1507
  sender: e
1499
1508
  }), a = Q(n, [l.u256()]);
1500
- return Te(Number(a[0]) || 0);
1509
+ return Be(Number(a[0]) || 0);
1501
1510
  }
1502
- async function lr(e, t, r, o) {
1511
+ async function dr(e, t, r, o) {
1503
1512
  const n = o?.client ?? V, a = new N();
1504
1513
  let c = 0, i = 0;
1505
1514
  const s = await S(t, o);
@@ -1508,7 +1517,7 @@ async function lr(e, t, r, o) {
1508
1517
  }), c * i < 0)
1509
1518
  throw new Error("Invalid operations");
1510
1519
  const u = c > 0 || i > 0;
1511
- await Pe(
1520
+ await Ae(
1512
1521
  a,
1513
1522
  e,
1514
1523
  s,
@@ -1521,14 +1530,14 @@ async function lr(e, t, r, o) {
1521
1530
  transactionBlock: a,
1522
1531
  sender: e
1523
1532
  }), w = Q(m, [l.u256()]);
1524
- return Te(Number(w[0]) || 0);
1533
+ return Be(Number(w[0]) || 0);
1525
1534
  }
1526
- const dr = A(
1535
+ const pr = A(
1527
1536
  async (e, t) => {
1528
1537
  const r = new URLSearchParams();
1529
1538
  t?.cursor && r.set("cursor", t.cursor), r.set("userAddress", e);
1530
- const o = E(t), n = M(
1531
- `/navi/user/transactions?${r.toString()}&sdk=${O.version}`,
1539
+ const o = O(t), n = M(
1540
+ `/navi/user/transactions?${r.toString()}&sdk=${E.version}`,
1532
1541
  t
1533
1542
  );
1534
1543
  return (await fetch(n, {
@@ -1536,7 +1545,7 @@ const dr = A(
1536
1545
  }).then((c) => c.json())).data;
1537
1546
  }
1538
1547
  );
1539
- async function pr(e, t) {
1548
+ async function mr(e, t) {
1540
1549
  let r = null;
1541
1550
  const o = [], n = t?.client ?? V, a = n.core;
1542
1551
  do {
@@ -1609,9 +1618,9 @@ async function pr(e, t) {
1609
1618
  } while (r);
1610
1619
  return o;
1611
1620
  }
1612
- const Pt = $(
1621
+ const At = $(
1613
1622
  async (e, t) => {
1614
- const r = [], o = (t?.markets || Object.keys(F)).map((i) => _(i)), n = await Be(e, t), a = o.map((i) => ({
1623
+ const r = [], o = (t?.markets || Object.keys(F)).map((i) => _(i)), n = await Pe(e, t), a = o.map((i) => ({
1615
1624
  address: e,
1616
1625
  market: i.key
1617
1626
  })).concat(
@@ -1621,7 +1630,7 @@ const Pt = $(
1621
1630
  emodeId: i.emodeId
1622
1631
  }))
1623
1632
  );
1624
- return (await Ae(e, a, t)).forEach((i) => {
1633
+ return (await Se(e, a, t)).forEach((i) => {
1625
1634
  const s = typeof i.emodeId == "number" ? n.find((u) => {
1626
1635
  const m = _(i.market);
1627
1636
  return u.emodeId === i.emodeId && u.marketId === m.id;
@@ -1947,7 +1956,7 @@ class L {
1947
1956
  };
1948
1957
  }
1949
1958
  }
1950
- async function mr(e, t, r, o) {
1959
+ async function fr(e, t, r, o) {
1951
1960
  const n = await j({
1952
1961
  ...o,
1953
1962
  cacheTime: v
@@ -1963,33 +1972,37 @@ async function mr(e, t, r, o) {
1963
1972
  ]
1964
1973
  });
1965
1974
  }
1966
- const Se = new Ce("https://hermes.pyth.network", {
1967
- timeout: 1e4
1968
- });
1969
- async function fr(e) {
1975
+ const fe = /* @__PURE__ */ new Map(), $e = (e) => {
1976
+ const t = e ?? "https://hermes.pyth.network";
1977
+ let r = fe.get(t);
1978
+ return r || (r = new je(t, { timeout: 1e4 }), fe.set(t, r)), r;
1979
+ };
1980
+ async function yr(e, t) {
1970
1981
  try {
1971
- const t = [], r = await Se.getLatestPriceFeeds(e);
1972
- if (!r) return t;
1973
- const o = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1974
- for (const n of r) {
1975
- const a = n.getPriceUnchecked();
1976
- if (a.publishTime > o) {
1982
+ const r = [], o = await j({ ...t, cacheTime: v }), n = await $e(
1983
+ o.oracle.hermesEndpoint
1984
+ ).getLatestPriceFeeds(e);
1985
+ if (!n) return r;
1986
+ const a = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1987
+ for (const c of n) {
1988
+ const i = c.getPriceUnchecked();
1989
+ if (i.publishTime > a) {
1977
1990
  console.warn(
1978
- `pyth price feed is invalid, id: ${n.id}, publish time: ${a.publishTime}, current timestamp: ${o}`
1991
+ `pyth price feed is invalid, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
1979
1992
  );
1980
1993
  continue;
1981
1994
  }
1982
- o - n.getPriceUnchecked().publishTime > 30 && (console.info(
1983
- `stale price feed, id: ${n.id}, publish time: ${a.publishTime}, current timestamp: ${o}`
1984
- ), t.push(n.id));
1995
+ a - c.getPriceUnchecked().publishTime > 30 && (console.info(
1996
+ `stale price feed, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
1997
+ ), r.push(c.id));
1985
1998
  }
1986
- return t;
1987
- } catch (t) {
1988
- throw new Error(`failed to get pyth stale price feed id, msg: ${t.message}`);
1999
+ return r;
2000
+ } catch (r) {
2001
+ throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
1989
2002
  }
1990
2003
  }
1991
- async function At(e, t) {
1992
- const r = [], o = t?.client ?? V, n = e.map((c) => c.priceInfoObject), a = await gt(o, {
2004
+ async function St(e, t) {
2005
+ const r = [], o = t?.client ?? V, n = e.map((c) => c.priceInfoObject), a = await ht(o, {
1993
2006
  ids: Array.from(new Set(n)),
1994
2007
  options: { showContent: !0 }
1995
2008
  });
@@ -2021,9 +2034,9 @@ async function At(e, t) {
2021
2034
  }
2022
2035
  return r;
2023
2036
  }
2024
- async function St(e, t) {
2037
+ async function $t(e, t) {
2025
2038
  try {
2026
- const r = [], o = await At(e, t);
2039
+ const r = [], o = await St(e, t);
2027
2040
  if (!o) return r;
2028
2041
  const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
2029
2042
  for (const a of o) {
@@ -2043,14 +2056,16 @@ async function St(e, t) {
2043
2056
  throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
2044
2057
  }
2045
2058
  }
2046
- async function $t(e, t, r) {
2059
+ async function Et(e, t, r) {
2047
2060
  const o = r?.client ?? V, n = await j({
2048
2061
  ...r,
2049
2062
  cacheTime: v
2050
2063
  });
2051
2064
  try {
2052
- const a = await Se.getPriceFeedsUpdateData(t);
2053
- return await new lt(
2065
+ const a = await $e(
2066
+ n.oracle.hermesEndpoint
2067
+ ).getPriceFeedsUpdateData(t);
2068
+ return await new dt(
2054
2069
  o,
2055
2070
  n.oracle.pythStateId,
2056
2071
  n.oracle.wormholeStateId
@@ -2059,7 +2074,7 @@ async function $t(e, t, r) {
2059
2074
  throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
2060
2075
  }
2061
2076
  }
2062
- async function fe(e, t, r) {
2077
+ async function ye(e, t, r) {
2063
2078
  const o = await j({
2064
2079
  ...r,
2065
2080
  cacheTime: v
@@ -2069,28 +2084,12 @@ async function fe(e, t, r) {
2069
2084
  priceFeedId: c.pythPriceFeedId,
2070
2085
  priceInfoObject: c.pythPriceInfoObject,
2071
2086
  expiration: 30
2072
- })), a = await St(n, r);
2073
- a.length > 0 && await $t(e, a, r);
2087
+ })), a = await $t(n, r);
2088
+ a.length > 0 && await Et(e, a, r);
2074
2089
  }
2075
2090
  for (const n of t)
2076
- r?.env === "dev" ? e.moveCall({
2077
- target: `${o.oracle.packageId}::oracle_pro::update_single_price`,
2078
- arguments: [
2079
- e.object("0x6"),
2080
- // Clock object
2081
- e.object(o.oracle.oracleConfig),
2082
- // Oracle configuration
2083
- e.object(o.oracle.priceOracle),
2084
- // Price oracle contract
2085
- e.object(o.oracle.supraOracleHolder),
2086
- // Supra oracle holder
2087
- e.object(n.pythPriceInfoObject),
2088
- // Pyth price info object
2089
- e.pure.address(n.feedId)
2090
- // Price feed ID
2091
- ]
2092
- }) : e.moveCall({
2093
- target: `${o.oracle.packageId}::oracle_pro::update_single_price_v2`,
2091
+ e.moveCall({
2092
+ target: `${o.oracle.packageId}::oracle_pro::${o.oracle.updateFunction ?? "update_single_price_v2"}`,
2094
2093
  arguments: [
2095
2094
  e.object("0x6"),
2096
2095
  // Clock object
@@ -2109,7 +2108,7 @@ async function fe(e, t, r) {
2109
2108
  });
2110
2109
  return e;
2111
2110
  }
2112
- async function $e(e) {
2111
+ async function Ee(e) {
2113
2112
  return (await j({
2114
2113
  ...e,
2115
2114
  cacheTime: v
@@ -2128,23 +2127,23 @@ function Ot(e, t) {
2128
2127
  return r.oracleId === c?.oracleId;
2129
2128
  }) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
2130
2129
  }
2131
- async function yr(e, t, r, o) {
2130
+ async function gr(e, t, r, o) {
2132
2131
  let n;
2133
2132
  try {
2134
- const a = await $e({
2133
+ const a = await Ee({
2135
2134
  ...o
2136
2135
  }), c = [];
2137
2136
  r.forEach((u) => {
2138
2137
  c.includes(u.market) || c.push(u.market);
2139
2138
  });
2140
- const i = await Pt(t, {
2139
+ const i = await At(t, {
2141
2140
  ...o,
2142
2141
  markets: c
2143
2142
  });
2144
2143
  return n = Ot(a, {
2145
2144
  lendingPositions: i,
2146
2145
  pools: r
2147
- }), await fe(e, n, {
2146
+ }), await ye(e, n, {
2148
2147
  updatePythPriceFeeds: !0,
2149
2148
  ...o
2150
2149
  });
@@ -2153,7 +2152,7 @@ async function yr(e, t, r, o) {
2153
2152
  throw a;
2154
2153
  if (console.error(a), n)
2155
2154
  try {
2156
- return await fe(e, n, {
2155
+ return await ye(e, n, {
2157
2156
  ...o,
2158
2157
  updatePythPriceFeeds: !1
2159
2158
  });
@@ -2166,8 +2165,8 @@ async function yr(e, t, r, o) {
2166
2165
  const ne = $(
2167
2166
  A(
2168
2167
  async (e) => {
2169
- const t = E(e), r = M(
2170
- `/navi/flashloan?env=${e?.env || "prod"}&sdk=${O.version}&market=${e?.market || R}`,
2168
+ const t = O(e), r = M(
2169
+ `/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${e?.market || R}`,
2171
2170
  e
2172
2171
  ), o = await fetch(r, {
2173
2172
  headers: U(D, t)
@@ -2179,10 +2178,10 @@ const ne = $(
2179
2178
  }
2180
2179
  )
2181
2180
  );
2182
- async function gr(e, t) {
2181
+ async function hr(e, t) {
2183
2182
  return (await ne(t)).find((o) => typeof e == "string" ? C(o.coinType) === C(e) : typeof e == "number" ? o.assetId === e : o.assetId === e.id) || null;
2184
2183
  }
2185
- async function hr(e, t, r, o) {
2184
+ async function wr(e, t, r, o) {
2186
2185
  const n = await j({
2187
2186
  ...o,
2188
2187
  cacheTime: v
@@ -2219,7 +2218,7 @@ async function hr(e, t, r, o) {
2219
2218
  return [s, u];
2220
2219
  }
2221
2220
  }
2222
- async function wr(e, t, r, o, n) {
2221
+ async function br(e, t, r, o, n) {
2223
2222
  const a = await j({
2224
2223
  ...n,
2225
2224
  cacheTime: v
@@ -2244,7 +2243,7 @@ async function wr(e, t, r, o, n) {
2244
2243
  });
2245
2244
  return [u];
2246
2245
  }
2247
- async function br(e, t, r, o, n, a) {
2246
+ async function vr(e, t, r, o, n, a) {
2248
2247
  const c = {
2249
2248
  ...a,
2250
2249
  cacheTime: v
@@ -2313,12 +2312,12 @@ async function br(e, t, r, o, n, a) {
2313
2312
  return [m, w];
2314
2313
  }
2315
2314
  }
2316
- async function Et(e, t, r) {
2315
+ async function Vt(e, t, r) {
2317
2316
  const o = r?.client ?? V, n = await G({
2318
2317
  ...r,
2319
2318
  markets: Object.values(F),
2320
2319
  cacheTime: v
2321
- }), a = await $e(r), c = [];
2320
+ }), a = await Ee(r), c = [];
2322
2321
  return await Promise.all(
2323
2322
  t.map(async (i) => {
2324
2323
  try {
@@ -2362,9 +2361,9 @@ async function Et(e, t, r) {
2362
2361
  const g = y[0].length;
2363
2362
  for (let d = 0; d < g; d++) {
2364
2363
  const f = a.find(
2365
- (I) => C(I.coinType) === C(y[1][d])
2364
+ (k) => C(k.coinType) === C(y[1][d])
2366
2365
  ), b = n.find(
2367
- (I) => C(I.coinType) === C(y[0][d]) && I.market === i.market
2366
+ (k) => C(k.coinType) === C(y[0][d]) && k.market === i.market
2368
2367
  );
2369
2368
  !f || !b || c.push({
2370
2369
  assetId: b.id,
@@ -2389,8 +2388,8 @@ async function Et(e, t, r) {
2389
2388
  })
2390
2389
  ), c;
2391
2390
  }
2392
- async function vr(e, t) {
2393
- const r = (t?.markets || [F.main]).map((a) => _(a)), o = await Be(e, t), n = r.map((a) => ({
2391
+ async function Cr(e, t) {
2392
+ const r = (t?.markets || [F.main]).map((a) => _(a)), o = await Pe(e, t), n = r.map((a) => ({
2394
2393
  address: e,
2395
2394
  owner: e,
2396
2395
  market: a.key
@@ -2405,9 +2404,9 @@ async function vr(e, t) {
2405
2404
  };
2406
2405
  })
2407
2406
  );
2408
- return await Et(e, n, t);
2407
+ return await Vt(e, n, t);
2409
2408
  }
2410
- function Cr(e) {
2409
+ function jr(e) {
2411
2410
  const t = /* @__PURE__ */ new Map();
2412
2411
  e.forEach((o) => {
2413
2412
  const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
@@ -2436,10 +2435,10 @@ function Cr(e) {
2436
2435
  }))
2437
2436
  }));
2438
2437
  }
2439
- const jr = A(
2438
+ const kr = A(
2440
2439
  async (e, t) => {
2441
- const r = E(t), o = M(
2442
- `/navi/user/total_claimed_reward?userAddress=${e}&sdk=${O.version}&market=${t?.market || R}`,
2440
+ const r = O(t), o = M(
2441
+ `/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${t?.market || R}`,
2443
2442
  t
2444
2443
  );
2445
2444
  return (await fetch(o, {
@@ -2448,8 +2447,8 @@ const jr = A(
2448
2447
  }
2449
2448
  ), Ir = A(
2450
2449
  async (e, t) => {
2451
- const r = E(t), o = M(
2452
- `/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${O.version}&market=${t?.market || R}`,
2450
+ const r = O(t), o = M(
2451
+ `/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${E.version}&market=${t?.market || R}`,
2453
2452
  t
2454
2453
  ), n = await fetch(o, {
2455
2454
  headers: U(D, r)
@@ -2459,7 +2458,7 @@ const jr = A(
2459
2458
  });
2460
2459
  }
2461
2460
  );
2462
- async function kr(e, t, r) {
2461
+ async function _r(e, t, r) {
2463
2462
  const o = await G({
2464
2463
  ...r,
2465
2464
  markets: Object.values(F),
@@ -2491,17 +2490,17 @@ async function kr(e, t, r) {
2491
2490
  cacheTime: v,
2492
2491
  market: m
2493
2492
  }), f = c.split("___")[0], b = o.filter(
2494
- (k) => C(k.suiCoinType) === C(f)
2493
+ (I) => C(I.suiCoinType) === C(f)
2495
2494
  );
2496
- b.sort((k, B) => k.market === m ? -1 : 1);
2497
- const I = b[0], T = d.rewardFunds[C(f)];
2495
+ b.sort((I, B) => I.market === m ? -1 : 1);
2496
+ const k = b[0], T = d.rewardFunds[C(f)];
2498
2497
  if (!T)
2499
2498
  throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
2500
2499
  if (r?.accountCap && !r.customCoinReceive)
2501
2500
  throw new Error("customCoinReceive is required when accountCap is provided");
2502
2501
  if (r?.customCoinReceive) {
2503
- let k;
2504
- r.accountCap ? k = e.moveCall({
2502
+ let I;
2503
+ r.accountCap ? I = e.moveCall({
2505
2504
  target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
2506
2505
  arguments: [
2507
2506
  e.object("0x06"),
@@ -2520,7 +2519,7 @@ async function kr(e, t, r) {
2520
2519
  // Account capability
2521
2520
  ],
2522
2521
  typeArguments: [f]
2523
- }) : g ? k = e.moveCall({
2522
+ }) : g ? I = e.moveCall({
2524
2523
  target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
2525
2524
  arguments: [
2526
2525
  e.object("0x06"),
@@ -2539,7 +2538,7 @@ async function kr(e, t, r) {
2539
2538
  // Account capability
2540
2539
  ],
2541
2540
  typeArguments: [f]
2542
- }) : k = e.moveCall({
2541
+ }) : I = e.moveCall({
2543
2542
  target: `${d.package}::incentive_v3::claim_reward`,
2544
2543
  arguments: [
2545
2544
  e.object("0x06"),
@@ -2559,7 +2558,7 @@ async function kr(e, t, r) {
2559
2558
  });
2560
2559
  const [B] = e.moveCall({
2561
2560
  target: "0x2::coin::from_balance",
2562
- arguments: [k],
2561
+ arguments: [I],
2563
2562
  typeArguments: [f]
2564
2563
  });
2565
2564
  if (r?.customCoinReceive.type === "transfer") {
@@ -2571,23 +2570,23 @@ async function kr(e, t, r) {
2571
2570
  );
2572
2571
  }
2573
2572
  if (r?.customCoinReceive.type === "depositNAVI") {
2574
- const W = p(I.totalSupplyAmount).shiftedBy(-9), Y = p(I.supplyCapCeiling).shiftedBy(-27);
2573
+ const W = p(k.totalSupplyAmount).shiftedBy(-9), Y = p(k.supplyCapCeiling).shiftedBy(-27);
2575
2574
  W.plus(u).isGreaterThan(Y) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
2576
2575
  [B],
2577
2576
  e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
2578
- ) : await vt(e, I, B, {
2577
+ ) : await Ct(e, k, B, {
2579
2578
  ...r,
2580
- market: I.market
2579
+ market: k.market
2581
2580
  });
2582
2581
  } else
2583
2582
  a.push({
2584
2583
  coin: B,
2585
- identifier: I,
2584
+ identifier: k,
2586
2585
  owner: w,
2587
2586
  isEMode: g
2588
2587
  });
2589
2588
  } else if (r?.accountCap || g) {
2590
- const k = e.moveCall({
2589
+ const I = e.moveCall({
2591
2590
  target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
2592
2591
  arguments: [
2593
2592
  e.object("0x06"),
@@ -2608,7 +2607,7 @@ async function kr(e, t, r) {
2608
2607
  typeArguments: [f]
2609
2608
  }), [B] = e.moveCall({
2610
2609
  target: "0x2::coin::from_balance",
2611
- arguments: [k],
2610
+ arguments: [I],
2612
2611
  typeArguments: [f]
2613
2612
  });
2614
2613
  e.transferObjects(
@@ -2641,84 +2640,84 @@ export {
2641
2640
  oe as Address,
2642
2641
  v as DEFAULT_CACHE_TIME,
2643
2642
  R as DEFAULT_MARKET_IDENTITY,
2644
- Wt as FlashLoanAssetConfig,
2645
- qt as IncentiveAPYInfo,
2646
- Le as IncentivePoolInfo,
2647
- zt as IncentivePoolInfoByPhase,
2643
+ Ht as FlashLoanAssetConfig,
2644
+ zt as IncentiveAPYInfo,
2645
+ qe as IncentivePoolInfo,
2646
+ Gt as IncentivePoolInfoByPhase,
2648
2647
  F as MARKETS,
2649
- Ct as Market,
2650
- Ke as NaviMissingGraphQLClientError,
2651
- Gt as OracleInfo,
2652
- et as PUBLIC_MAINNET_GRPC_URL,
2648
+ jt as Market,
2649
+ Qe as NaviMissingGraphQLClientError,
2650
+ Wt as OracleInfo,
2651
+ tt as PUBLIC_MAINNET_GRPC_URL,
2653
2652
  z as PoolOperator,
2654
- qe as ReserveDataInfo,
2655
- Ce as SuiPriceServiceConnection,
2656
- lt as SuiPythClient,
2653
+ ze as ReserveDataInfo,
2654
+ je as SuiPriceServiceConnection,
2655
+ dt as SuiPythClient,
2657
2656
  L as UserPositions,
2658
- ze as UserStateInfo,
2659
- er as borrowCoinPTB,
2657
+ Ge as UserStateInfo,
2658
+ tr as borrowCoinPTB,
2660
2659
  M as buildNaviOpenApiUrl,
2661
- kr as claimLendingRewardsPTB,
2662
- Yt as configureNaviSdk,
2660
+ _r as claimLendingRewardsPTB,
2661
+ Zt as configureNaviSdk,
2663
2662
  It as createAccountCapPTB,
2664
- ar as createEModeCapPTB,
2665
- ve as createNaviLegacyJsonRpcClient,
2666
- rt as createNaviSuiClient,
2667
- xe as createNaviSuiClientBundle,
2668
- vt as depositCoinPTB,
2669
- ir as emodeIdentityId,
2670
- _t as enterEModePTB,
2671
- or as exitEModePTB,
2663
+ ir as createEModeCapPTB,
2664
+ Ce as createNaviLegacyJsonRpcClient,
2665
+ nt as createNaviSuiClient,
2666
+ et as createNaviSuiClientBundle,
2667
+ Ct as depositCoinPTB,
2668
+ cr as emodeIdentityId,
2669
+ Tt as enterEModePTB,
2670
+ ar as exitEModePTB,
2672
2671
  Ot as filterPriceFeeds,
2673
- hr as flashloanPTB,
2674
- kt as getAccountCapOwnerPTB,
2675
- Jt as getAddressBalance,
2672
+ wr as flashloanPTB,
2673
+ _t as getAccountCapOwnerPTB,
2674
+ Kt as getAddressBalance,
2676
2675
  ne as getAllFlashLoanAssets,
2677
- rr as getBorrowFee,
2678
- Ht as getCoinObjectOnlyBalance,
2679
- pr as getCoins,
2676
+ nr as getBorrowFee,
2677
+ Jt as getCoinObjectOnlyBalance,
2678
+ mr as getCoins,
2680
2679
  j as getConfig,
2681
- Xt as getFees,
2682
- gr as getFlashLoanAsset,
2683
- ur as getHealthFactor,
2684
- Bt as getHealthFactorPTB,
2685
- Pt as getLendingPositions,
2686
- sr as getLendingState,
2687
- nr as getMarket,
2680
+ xt as getFees,
2681
+ hr as getFlashLoanAsset,
2682
+ lr as getHealthFactor,
2683
+ Pt as getHealthFactorPTB,
2684
+ At as getLendingPositions,
2685
+ ur as getLendingState,
2686
+ or as getMarket,
2688
2687
  _ as getMarketConfig,
2689
- jt as getMarkets,
2688
+ kt as getMarkets,
2690
2689
  S as getPool,
2691
2690
  G as getPools,
2692
- $e as getPriceFeeds,
2693
- fr as getPythStalePriceFeedId,
2694
- St as getPythStalePriceFeedIdV2,
2695
- lr as getSimulatedHealthFactor,
2696
- Pe as getSimulatedHealthFactorPTB,
2697
- Zt as getStats,
2698
- dr as getTransactions,
2699
- vr as getUserAvailableLendingRewards,
2691
+ Ee as getPriceFeeds,
2692
+ yr as getPythStalePriceFeedId,
2693
+ $t as getPythStalePriceFeedIdV2,
2694
+ dr as getSimulatedHealthFactor,
2695
+ Ae as getSimulatedHealthFactorPTB,
2696
+ Xt as getStats,
2697
+ pr as getTransactions,
2698
+ Cr as getUserAvailableLendingRewards,
2700
2699
  Ir as getUserClaimedRewardHistory,
2701
- Be as getUserEModeCaps,
2702
- jr as getUserTotalClaimedReward,
2703
- br as liquidatePTB,
2704
- Kt as listAddressBalances,
2705
- cr as mergeCoinsPTB,
2700
+ Pe as getUserEModeCaps,
2701
+ kr as getUserTotalClaimedReward,
2702
+ vr as liquidatePTB,
2703
+ Qt as listAddressBalances,
2704
+ sr as mergeCoinsPTB,
2706
2705
  U as mergeServiceHeaders,
2707
- be as normalizeAddressBalance,
2706
+ ve as normalizeAddressBalance,
2708
2707
  C as normalizeCoinType,
2709
- bt as parsePoolUID,
2708
+ vt as parsePoolUID,
2710
2709
  h as parseTxValue,
2711
- tr as repayCoinPTB,
2712
- wr as repayFlashLoanPTB,
2713
- Qt as requireNaviGraphQLClient,
2714
- E as resolveNaviOpenApiEndpoint,
2715
- Cr as summaryLendingRewards,
2716
- yr as updateOraclePriceBeforeUserOperationPTB,
2717
- fe as updateOraclePricesPTB,
2718
- $t as updatePythPriceFeeds,
2719
- mr as verifyHealthFactorPTB,
2710
+ rr as repayCoinPTB,
2711
+ br as repayFlashLoanPTB,
2712
+ Yt as requireNaviGraphQLClient,
2713
+ O as resolveNaviOpenApiEndpoint,
2714
+ jr as summaryLendingRewards,
2715
+ gr as updateOraclePriceBeforeUserOperationPTB,
2716
+ ye as updateOraclePricesPTB,
2717
+ Et as updatePythPriceFeeds,
2718
+ fr as verifyHealthFactorPTB,
2720
2719
  $ as withCache,
2721
2720
  A as withSingleton,
2722
- xt as withdrawCoinPTB
2721
+ er as withdrawCoinPTB
2723
2722
  };
2724
2723
  //# sourceMappingURL=index.esm.js.map