@naviprotocol/lending 2.0.3 → 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.3", E = {
133
- version: Ge
134
- }, We = E.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,15 +555,15 @@ 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
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
  }
@@ -562,7 +571,7 @@ function M(e, t) {
562
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,9 +621,9 @@ async function q(e, t) {
612
621
  commandResults: !0
613
622
  }
614
623
  });
615
- return ft(n);
624
+ return yt(n);
616
625
  }
617
- function ke(e) {
626
+ function Ie(e) {
618
627
  return {
619
628
  json: !!e?.showContent,
620
629
  display: !!e?.showDisplay,
@@ -622,7 +631,7 @@ function ke(e) {
622
631
  objectBcs: !!e?.showBcs
623
632
  };
624
633
  }
625
- function Ie(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,27 +651,27 @@ function Ie(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");
649
658
  const { object: o } = await r.getObject({
650
659
  objectId: t.id,
651
- include: ke(t.options)
660
+ include: Ie(t.options)
652
661
  });
653
- return Ie(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");
659
668
  const { objects: o } = await r.getObjects({
660
669
  objectIds: t.ids,
661
- include: ke(t.options)
670
+ include: Ie(t.options)
662
671
  });
663
- return o.map(Ie);
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,
@@ -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,14 +827,14 @@ 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
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
840
  const t = O(e), r = M(`/navi/fee?sdk=${E.version}`, e);
@@ -835,7 +844,7 @@ const Zt = $(
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,13 +1251,13 @@ 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(
@@ -1263,7 +1272,7 @@ const _ = (e) => {
1263
1272
  }
1264
1273
  )
1265
1274
  ), v = 1e3 * 60 * 5;
1266
- async function kt(e, t) {
1275
+ async function It(e, t) {
1267
1276
  const r = await j({
1268
1277
  cacheTime: v,
1269
1278
  ...t
@@ -1273,7 +1282,7 @@ async function kt(e, t) {
1273
1282
  arguments: []
1274
1283
  });
1275
1284
  }
1276
- async function It(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 It(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
- }), n = await kt(e, r);
1321
- await _t(e, t, {
1329
+ }), n = await It(e, r);
1330
+ await Tt(e, t, {
1322
1331
  ...r,
1323
1332
  accountCap: n
1324
1333
  });
1325
- const a = await _(r?.market || R), c = await It(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,7 +1455,7 @@ 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] || [], k = {};
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
1460
  k[T.id] = {
1452
1461
  supplyIndex: T.supply_index,
@@ -1460,7 +1469,7 @@ 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
1474
  const b = t[f], k = _(b.market), T = w[k.key] || {};
1466
1475
  d.forEach((I) => {
@@ -1469,10 +1478,10 @@ async function Ae(e, t, r) {
1469
1478
  const B = c[`${k.key}-${I.asset_id}`];
1470
1479
  if (!B)
1471
1480
  return;
1472
- const W = T[I.asset_id], Y = W?.supplyIndex ?? B.currentSupplyIndex, Ee = W?.borrowIndex ?? B.currentBorrowIndex, Oe = de(I.supply_balance, Y).toString(), Ve = de(I.borrow_balance, Ee).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: Oe,
1475
- borrowBalance: Ve,
1483
+ supplyBalance: Ve,
1484
+ borrowBalance: Me,
1476
1485
  assetId: I.asset_id,
1477
1486
  market: k.key,
1478
1487
  pool: B,
@@ -1481,25 +1490,25 @@ async function Ae(e, t, r) {
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,9 +1530,9 @@ 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);
@@ -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,12 +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
2091
  e.moveCall({
2077
- target: `${o.oracle.packageId}::oracle_pro::update_single_price_v2`,
2092
+ target: `${o.oracle.packageId}::oracle_pro::${o.oracle.updateFunction ?? "update_single_price_v2"}`,
2078
2093
  arguments: [
2079
2094
  e.object("0x6"),
2080
2095
  // Clock object
@@ -2093,13 +2108,13 @@ async function fe(e, t, r) {
2093
2108
  });
2094
2109
  return e;
2095
2110
  }
2096
- async function $e(e) {
2111
+ async function Ee(e) {
2097
2112
  return (await j({
2098
2113
  ...e,
2099
2114
  cacheTime: v
2100
2115
  })).oracle.feeds;
2101
2116
  }
2102
- function Et(e, t) {
2117
+ function Ot(e, t) {
2103
2118
  return e.filter((r) => !!(t?.lendingState && t.lendingState.find((n) => r.oracleId === n.pool.oracleId) || t?.lendingPositions && t.lendingPositions.find((n) => {
2104
2119
  if (![
2105
2120
  "navi-lending-supply",
@@ -2112,23 +2127,23 @@ function Et(e, t) {
2112
2127
  return r.oracleId === c?.oracleId;
2113
2128
  }) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
2114
2129
  }
2115
- async function yr(e, t, r, o) {
2130
+ async function gr(e, t, r, o) {
2116
2131
  let n;
2117
2132
  try {
2118
- const a = await $e({
2133
+ const a = await Ee({
2119
2134
  ...o
2120
2135
  }), c = [];
2121
2136
  r.forEach((u) => {
2122
2137
  c.includes(u.market) || c.push(u.market);
2123
2138
  });
2124
- const i = await Pt(t, {
2139
+ const i = await At(t, {
2125
2140
  ...o,
2126
2141
  markets: c
2127
2142
  });
2128
- return n = Et(a, {
2143
+ return n = Ot(a, {
2129
2144
  lendingPositions: i,
2130
2145
  pools: r
2131
- }), await fe(e, n, {
2146
+ }), await ye(e, n, {
2132
2147
  updatePythPriceFeeds: !0,
2133
2148
  ...o
2134
2149
  });
@@ -2137,7 +2152,7 @@ async function yr(e, t, r, o) {
2137
2152
  throw a;
2138
2153
  if (console.error(a), n)
2139
2154
  try {
2140
- return await fe(e, n, {
2155
+ return await ye(e, n, {
2141
2156
  ...o,
2142
2157
  updatePythPriceFeeds: !1
2143
2158
  });
@@ -2163,10 +2178,10 @@ const ne = $(
2163
2178
  }
2164
2179
  )
2165
2180
  );
2166
- async function gr(e, t) {
2181
+ async function hr(e, t) {
2167
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;
2168
2183
  }
2169
- async function hr(e, t, r, o) {
2184
+ async function wr(e, t, r, o) {
2170
2185
  const n = await j({
2171
2186
  ...o,
2172
2187
  cacheTime: v
@@ -2203,7 +2218,7 @@ async function hr(e, t, r, o) {
2203
2218
  return [s, u];
2204
2219
  }
2205
2220
  }
2206
- async function wr(e, t, r, o, n) {
2221
+ async function br(e, t, r, o, n) {
2207
2222
  const a = await j({
2208
2223
  ...n,
2209
2224
  cacheTime: v
@@ -2228,7 +2243,7 @@ async function wr(e, t, r, o, n) {
2228
2243
  });
2229
2244
  return [u];
2230
2245
  }
2231
- async function br(e, t, r, o, n, a) {
2246
+ async function vr(e, t, r, o, n, a) {
2232
2247
  const c = {
2233
2248
  ...a,
2234
2249
  cacheTime: v
@@ -2297,12 +2312,12 @@ async function br(e, t, r, o, n, a) {
2297
2312
  return [m, w];
2298
2313
  }
2299
2314
  }
2300
- async function Ot(e, t, r) {
2315
+ async function Vt(e, t, r) {
2301
2316
  const o = r?.client ?? V, n = await G({
2302
2317
  ...r,
2303
2318
  markets: Object.values(F),
2304
2319
  cacheTime: v
2305
- }), a = await $e(r), c = [];
2320
+ }), a = await Ee(r), c = [];
2306
2321
  return await Promise.all(
2307
2322
  t.map(async (i) => {
2308
2323
  try {
@@ -2373,8 +2388,8 @@ async function Ot(e, t, r) {
2373
2388
  })
2374
2389
  ), c;
2375
2390
  }
2376
- async function vr(e, t) {
2377
- 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) => ({
2378
2393
  address: e,
2379
2394
  owner: e,
2380
2395
  market: a.key
@@ -2389,9 +2404,9 @@ async function vr(e, t) {
2389
2404
  };
2390
2405
  })
2391
2406
  );
2392
- return await Ot(e, n, t);
2407
+ return await Vt(e, n, t);
2393
2408
  }
2394
- function Cr(e) {
2409
+ function jr(e) {
2395
2410
  const t = /* @__PURE__ */ new Map();
2396
2411
  e.forEach((o) => {
2397
2412
  const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
@@ -2420,7 +2435,7 @@ function Cr(e) {
2420
2435
  }))
2421
2436
  }));
2422
2437
  }
2423
- const jr = A(
2438
+ const kr = A(
2424
2439
  async (e, t) => {
2425
2440
  const r = O(t), o = M(
2426
2441
  `/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${t?.market || R}`,
@@ -2430,7 +2445,7 @@ const jr = A(
2430
2445
  headers: U(D, r)
2431
2446
  }).then((a) => a.json())).data;
2432
2447
  }
2433
- ), kr = A(
2448
+ ), Ir = A(
2434
2449
  async (e, t) => {
2435
2450
  const r = O(t), o = M(
2436
2451
  `/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${E.version}&market=${t?.market || R}`,
@@ -2443,7 +2458,7 @@ const jr = A(
2443
2458
  });
2444
2459
  }
2445
2460
  );
2446
- async function Ir(e, t, r) {
2461
+ async function _r(e, t, r) {
2447
2462
  const o = await G({
2448
2463
  ...r,
2449
2464
  markets: Object.values(F),
@@ -2559,7 +2574,7 @@ async function Ir(e, t, r) {
2559
2574
  W.plus(u).isGreaterThan(Y) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
2560
2575
  [B],
2561
2576
  e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
2562
- ) : await vt(e, k, B, {
2577
+ ) : await Ct(e, k, B, {
2563
2578
  ...r,
2564
2579
  market: k.market
2565
2580
  });
@@ -2625,84 +2640,84 @@ export {
2625
2640
  oe as Address,
2626
2641
  v as DEFAULT_CACHE_TIME,
2627
2642
  R as DEFAULT_MARKET_IDENTITY,
2628
- Wt as FlashLoanAssetConfig,
2629
- qt as IncentiveAPYInfo,
2630
- Le as IncentivePoolInfo,
2631
- zt as IncentivePoolInfoByPhase,
2643
+ Ht as FlashLoanAssetConfig,
2644
+ zt as IncentiveAPYInfo,
2645
+ qe as IncentivePoolInfo,
2646
+ Gt as IncentivePoolInfoByPhase,
2632
2647
  F as MARKETS,
2633
- Ct as Market,
2634
- Ke as NaviMissingGraphQLClientError,
2635
- Gt as OracleInfo,
2636
- 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,
2637
2652
  z as PoolOperator,
2638
- qe as ReserveDataInfo,
2639
- Ce as SuiPriceServiceConnection,
2640
- lt as SuiPythClient,
2653
+ ze as ReserveDataInfo,
2654
+ je as SuiPriceServiceConnection,
2655
+ dt as SuiPythClient,
2641
2656
  L as UserPositions,
2642
- ze as UserStateInfo,
2643
- er as borrowCoinPTB,
2657
+ Ge as UserStateInfo,
2658
+ tr as borrowCoinPTB,
2644
2659
  M as buildNaviOpenApiUrl,
2645
- Ir as claimLendingRewardsPTB,
2646
- Yt as configureNaviSdk,
2647
- kt as createAccountCapPTB,
2648
- ar as createEModeCapPTB,
2649
- ve as createNaviLegacyJsonRpcClient,
2650
- rt as createNaviSuiClient,
2651
- xe as createNaviSuiClientBundle,
2652
- vt as depositCoinPTB,
2653
- ir as emodeIdentityId,
2654
- _t as enterEModePTB,
2655
- or as exitEModePTB,
2656
- Et as filterPriceFeeds,
2657
- hr as flashloanPTB,
2658
- It as getAccountCapOwnerPTB,
2659
- Jt as getAddressBalance,
2660
+ _r as claimLendingRewardsPTB,
2661
+ Zt as configureNaviSdk,
2662
+ It as createAccountCapPTB,
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,
2671
+ Ot as filterPriceFeeds,
2672
+ wr as flashloanPTB,
2673
+ _t as getAccountCapOwnerPTB,
2674
+ Kt as getAddressBalance,
2660
2675
  ne as getAllFlashLoanAssets,
2661
- rr as getBorrowFee,
2662
- Ht as getCoinObjectOnlyBalance,
2663
- pr as getCoins,
2676
+ nr as getBorrowFee,
2677
+ Jt as getCoinObjectOnlyBalance,
2678
+ mr as getCoins,
2664
2679
  j as getConfig,
2665
- Xt as getFees,
2666
- gr as getFlashLoanAsset,
2667
- ur as getHealthFactor,
2668
- Bt as getHealthFactorPTB,
2669
- Pt as getLendingPositions,
2670
- sr as getLendingState,
2671
- 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,
2672
2687
  _ as getMarketConfig,
2673
- jt as getMarkets,
2688
+ kt as getMarkets,
2674
2689
  S as getPool,
2675
2690
  G as getPools,
2676
- $e as getPriceFeeds,
2677
- fr as getPythStalePriceFeedId,
2678
- St as getPythStalePriceFeedIdV2,
2679
- lr as getSimulatedHealthFactor,
2680
- Pe as getSimulatedHealthFactorPTB,
2681
- Zt as getStats,
2682
- dr as getTransactions,
2683
- vr as getUserAvailableLendingRewards,
2684
- kr as getUserClaimedRewardHistory,
2685
- Be as getUserEModeCaps,
2686
- jr as getUserTotalClaimedReward,
2687
- br as liquidatePTB,
2688
- Kt as listAddressBalances,
2689
- cr as mergeCoinsPTB,
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,
2699
+ Ir as getUserClaimedRewardHistory,
2700
+ Pe as getUserEModeCaps,
2701
+ kr as getUserTotalClaimedReward,
2702
+ vr as liquidatePTB,
2703
+ Qt as listAddressBalances,
2704
+ sr as mergeCoinsPTB,
2690
2705
  U as mergeServiceHeaders,
2691
- be as normalizeAddressBalance,
2706
+ ve as normalizeAddressBalance,
2692
2707
  C as normalizeCoinType,
2693
- bt as parsePoolUID,
2708
+ vt as parsePoolUID,
2694
2709
  h as parseTxValue,
2695
- tr as repayCoinPTB,
2696
- wr as repayFlashLoanPTB,
2697
- Qt as requireNaviGraphQLClient,
2710
+ rr as repayCoinPTB,
2711
+ br as repayFlashLoanPTB,
2712
+ Yt as requireNaviGraphQLClient,
2698
2713
  O as resolveNaviOpenApiEndpoint,
2699
- Cr as summaryLendingRewards,
2700
- yr as updateOraclePriceBeforeUserOperationPTB,
2701
- fe as updateOraclePricesPTB,
2702
- $t as updatePythPriceFeeds,
2703
- mr as verifyHealthFactorPTB,
2714
+ jr as summaryLendingRewards,
2715
+ gr as updateOraclePriceBeforeUserOperationPTB,
2716
+ ye as updateOraclePricesPTB,
2717
+ Et as updatePythPriceFeeds,
2718
+ fr as verifyHealthFactorPTB,
2704
2719
  $ as withCache,
2705
2720
  A as withSingleton,
2706
- xt as withdrawCoinPTB
2721
+ er as withdrawCoinPTB
2707
2722
  };
2708
2723
  //# sourceMappingURL=index.esm.js.map