@naviprotocol/lending 2.0.5-beta.1 → 2.0.5-beta.3

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 q } from "@mysten/sui/transactions";
2
2
  import { bcs as l } from "@mysten/sui/bcs";
3
- import { toHex as Ue, fromHex as Me, normalizeStructTag as Y, SUI_CLOCK_OBJECT_ID as x, fromBase64 as De } from "@mysten/sui/utils";
4
- import Fe from "lodash.camelcase";
3
+ import { toHex as Ue, fromHex as De, normalizeStructTag as Y, SUI_CLOCK_OBJECT_ID as x, 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 he, GrpcWebFetchTransport as be } 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 we, GrpcWebFetchTransport as be } from "@mysten/sui/grpc";
9
9
  const ie = l.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
- input: (e) => Me(e),
11
+ input: (e) => De(e),
12
12
  output: (e) => Ue(e)
13
- }), qt = l.struct("IncentiveAPYInfo", {
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: ie,
23
23
  /** Address holding the incentive funds */
@@ -44,12 +44,12 @@ const ie = 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 ie = 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 ie = 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 ie = 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.5-beta.1", V = {
133
- version: Ge
134
- }, We = V.version, He = () => {
132
+ }), We = "2.0.5-beta.3", V = {
133
+ version: We
134
+ }, He = V.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
- }, ce = Je(), we = "0x2::sui::SUI";
144
- class Ke extends Error {
142
+ return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${He} (${Je()})`), e;
143
+ }, ce = Ke(), ve = "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 ee(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 ve(e) {
160
+ function Ce(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 Ce(e, t = we) {
166
+ function je(e, t = ve) {
167
167
  const r = ee(e.addressBalance ?? e.fundsInAddressBalance) ?? "0";
168
168
  let o = ee(e.balance ?? e.totalBalance), n = ee(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: Y(e.coinType ?? t),
171
171
  totalBalance: o ?? "0",
172
172
  coinBalance: n ?? "0",
@@ -174,22 +174,22 @@ function Ce(e, t = we) {
174
174
  ...e.coinObjectCount === null || e.coinObjectCount === void 0 ? {} : { coinObjectCount: e.coinObjectCount }
175
175
  };
176
176
  }
177
- function Ht(e, t = we) {
177
+ function Jt(e, t = ve) {
178
178
  const r = Y(t);
179
179
  return e.filter((o) => Y(o.coinType) === r).reduce((o, n) => o + BigInt(n.balance), 0n).toString();
180
180
  }
181
- async function Jt(e, t) {
182
- const r = await ve(e).getBalance(t), o = r.balance;
183
- return Ce((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
184
- }
185
181
  async function Kt(e, t) {
186
- const r = await ve(e).listBalances(t), { balances: o = [] } = r;
182
+ const r = await Ce(e).getBalance(t), o = r.balance;
183
+ return je((o && typeof o == "object" ? o : r) ?? {}, t.coinType);
184
+ }
185
+ async function Qt(e, t) {
186
+ const r = await Ce(e).listBalances(t), { balances: o = [] } = r;
187
187
  return {
188
- balances: o.map((n) => Ce(n)),
188
+ balances: o.map((n) => je(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
195
  const r = new be({
@@ -198,53 +198,53 @@ function Ze(e, t) {
198
198
  fetchInit: t.fetchInit,
199
199
  fetch: t.fetch
200
200
  });
201
- return new he({
201
+ return new we({
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 ke(e, t) {
215
- return "client" in t ? t.client : new Ne({
214
+ function Ie(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 ? ke(e.network, e.legacyJsonRpc) : void 0,
226
+ graphql: e.graphql ? xe(e.network, e.graphql) : void 0,
227
+ legacyJsonRpc: e.legacyJsonRpc ? Ie(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 te;
238
- function tt() {
239
- return te || (te = new he({
238
+ function rt() {
239
+ return te || (te = new we({
240
240
  network: "mainnet",
241
- transport: new be({ baseUrl: et })
241
+ transport: new be({ baseUrl: tt })
242
242
  })), te;
243
243
  }
244
- function rt(e, t = "mainnet") {
245
- return e ? typeof e == "string" ? ke(t, { url: e }) : xe(e) : tt();
244
+ function nt(e, t = "mainnet") {
245
+ return e ? typeof e == "string" ? Ie(t, { url: e }) : et(e) : rt();
246
246
  }
247
- const nt = 16 * 1024;
247
+ const ot = 16 * 1024;
248
248
  function oe(e) {
249
249
  return e.replace(/^0x/i, "");
250
250
  }
@@ -254,12 +254,12 @@ function se(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 ue(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 le(e, t) {
@@ -268,17 +268,17 @@ function le(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 Ie {
302
+ class ke {
303
303
  constructor(t, r) {
304
304
  this.endpoint = t.replace(/\/$/, ""), this.timeout = r?.timeout ?? 1e4;
305
305
  }
@@ -327,7 +327,7 @@ class Ie {
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,7 +347,7 @@ class Ie {
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
  }
@@ -504,7 +504,7 @@ class lt {
504
504
  if (c) {
505
505
  const { dynamicField: i } = await c.getDynamicField({
506
506
  parentId: o,
507
- name: le(a, it(se(r)))
507
+ name: le(a, ct(se(r)))
508
508
  }), s = i?.value?.bcs;
509
509
  this.priceFeedObjectIdCache.set(
510
510
  r,
@@ -524,7 +524,7 @@ class lt {
524
524
  }
525
525
  async getPriceTableInfo() {
526
526
  if (!this.priceTableInfo) {
527
- const t = this.getCoreProvider() ? le("vector<u8>", at("price_info")) : {
527
+ const t = this.getCoreProvider() ? le("vector<u8>", it("price_info")) : {
528
528
  type: "vector<u8>",
529
529
  value: "price_info"
530
530
  }, r = await this.getDynamicMoveObjectJson(this.pythStateId, t);
@@ -532,22 +532,22 @@ class lt {
532
532
  throw new Error("Price Table not found, contract may not be initialized");
533
533
  this.priceTableInfo = {
534
534
  id: r.objectId,
535
- fieldType: st(r.type)
535
+ fieldType: ut(r.type)
536
536
  };
537
537
  }
538
538
  return this.priceTableInfo;
539
539
  }
540
540
  extractVaaBytesFromAccumulatorMessage(t) {
541
- 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;
542
542
  return t.subarray(a, a + n);
543
543
  }
544
544
  }
545
- const dt = "https://open-api.naviprotocol.io/api";
546
- let Q = {}, je = 0;
547
- function pt(e) {
545
+ const pt = "https://open-api.naviprotocol.io/api";
546
+ let Q = {}, _e = 0;
547
+ function mt(e) {
548
548
  return e.replace(/\/+$/, "");
549
549
  }
550
- function Yt(e) {
550
+ function Zt(e) {
551
551
  Q = {
552
552
  ...Q,
553
553
  ...e,
@@ -555,23 +555,23 @@ function Yt(e) {
555
555
  ...Q.services,
556
556
  ...e.services
557
557
  }
558
- }, je += 1;
558
+ }, _e += 1;
559
559
  }
560
560
  function de() {
561
- return je;
561
+ return _e;
562
562
  }
563
- function U(e) {
563
+ function M(e) {
564
564
  const t = e?.services?.naviOpenApi ?? Q.services?.naviOpenApi;
565
565
  return {
566
- baseUrl: pt(t?.baseUrl ?? dt),
566
+ baseUrl: mt(t?.baseUrl ?? pt),
567
567
  headers: t?.headers
568
568
  };
569
569
  }
570
570
  function F(e, t) {
571
- const r = U(t), o = e.startsWith("/") ? e : `/${e}`;
571
+ const r = M(t), o = e.startsWith("/") ? e : `/${e}`;
572
572
  return `${r.baseUrl}${o}`;
573
573
  }
574
- function mt(e) {
574
+ function ft(e) {
575
575
  if (e instanceof Headers) {
576
576
  const t = {};
577
577
  return e.forEach((r, o) => {
@@ -582,15 +582,15 @@ function mt(e) {
582
582
  }
583
583
  function N(e, t) {
584
584
  return {
585
- ...mt(e),
585
+ ...ft(e),
586
586
  ...t?.headers ?? {}
587
587
  };
588
588
  }
589
- const M = rt();
589
+ const U = nt();
590
590
  function pe(e) {
591
- 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)) : [];
592
592
  }
593
- function ft(e) {
593
+ function yt(e) {
594
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];
595
595
  return o && console.warn("[lending] devInspect(core simulate) returned error:", o), {
596
596
  effects: r.effects,
@@ -621,9 +621,9 @@ async function W(e, t) {
621
621
  commandResults: !0
622
622
  }
623
623
  });
624
- return ft(n);
624
+ return yt(n);
625
625
  }
626
- function _e(e) {
626
+ function Te(e) {
627
627
  return {
628
628
  json: !!e?.showContent,
629
629
  display: !!e?.showDisplay,
@@ -631,7 +631,7 @@ function _e(e) {
631
631
  objectBcs: !!e?.showBcs
632
632
  };
633
633
  }
634
- function Te(e) {
634
+ function Be(e) {
635
635
  return !e || e instanceof Error ? {
636
636
  error: e instanceof Error ? { code: "notFound", error: e.message } : void 0
637
637
  } : {
@@ -651,27 +651,27 @@ function Te(e) {
651
651
  }
652
652
  };
653
653
  }
654
- async function yt(e, t) {
654
+ async function gt(e, t) {
655
655
  const r = e?.core;
656
656
  if (typeof r?.getObject != "function")
657
657
  throw new Error("getSuiObject requires a Sui v2 Core-capable client");
658
658
  const { object: o } = await r.getObject({
659
659
  objectId: t.id,
660
- include: _e(t.options)
660
+ include: Te(t.options)
661
661
  });
662
- return Te(o);
662
+ return Be(o);
663
663
  }
664
- async function gt(e, t) {
664
+ async function ht(e, t) {
665
665
  const r = e?.core;
666
666
  if (typeof r?.getObjects != "function")
667
667
  throw new Error("multiGetSuiObjects requires a Sui v2 Core-capable client");
668
668
  const { objects: o } = await r.getObjects({
669
669
  objectIds: t.ids,
670
- include: _e(t.options)
670
+ include: Te(t.options)
671
671
  });
672
- return o.map(Te);
672
+ return o.map(Be);
673
673
  }
674
- function Be(e) {
674
+ function Pe(e) {
675
675
  const t = [];
676
676
  let r = !1;
677
677
  return e.forEach((o, n) => {
@@ -685,10 +685,10 @@ function Be(e) {
685
685
  __naviSdkServiceConfigVersion: de()
686
686
  }), JSON.stringify(t);
687
687
  }
688
- function A(e) {
688
+ function S(e) {
689
689
  const t = {};
690
690
  return (...r) => {
691
- const o = Be(r);
691
+ const o = Pe(r);
692
692
  return t[o] || (t[o] = e(...r).finally(() => {
693
693
  delete t[o];
694
694
  })), t[o];
@@ -697,7 +697,7 @@ function A(e) {
697
697
  function O(e) {
698
698
  let t = {};
699
699
  return (...r) => {
700
- const o = r[r.length - 1], n = Be(r), a = t[n];
700
+ const o = r[r.length - 1], n = Pe(r), a = t[n];
701
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] = {
702
702
  data: c,
703
703
  cacheAt: Date.now()
@@ -708,7 +708,7 @@ function re(e) {
708
708
  return Array.isArray(e) ? e.map((t) => re(t)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
709
709
  (t, r) => ({
710
710
  ...t,
711
- [Fe(r)]: re(e[r])
711
+ [Ne(r)]: re(e[r])
712
712
  }),
713
713
  {}
714
714
  ) : e;
@@ -718,7 +718,7 @@ function h(e, t) {
718
718
  throw new Error("Transaction value is required");
719
719
  return typeof e == "object" ? e : t(e);
720
720
  }
721
- function ht(e, t) {
721
+ function wt(e, t) {
722
722
  return typeof t == "string" ? e.object(t) : typeof t == "object" && t.$kind ? t : e.object(t.contract.pool);
723
723
  }
724
724
  function Z(e, t, r) {
@@ -732,11 +732,11 @@ function Z(e, t, r) {
732
732
  function C(e) {
733
733
  return Y(e);
734
734
  }
735
- function Pe(e) {
735
+ function Ae(e) {
736
736
  const t = (e || 0) / Math.pow(10, 27);
737
737
  return t > Math.pow(10, 5) ? 1 / 0 : t;
738
738
  }
739
- new Ie("https://hermes.pyth.network", {
739
+ new ke("https://hermes.pyth.network", {
740
740
  timeout: 2e4
741
741
  });
742
742
  const bt = 27, me = (e, t) => {
@@ -772,21 +772,21 @@ function K(e, t) {
772
772
  isEMode: !0
773
773
  };
774
774
  }
775
- function wt(e) {
775
+ function vt(e) {
776
776
  const [t, r] = e.split("-");
777
777
  return !t || !r ? null : {
778
778
  marketKey: t,
779
779
  poolId: parseInt(r)
780
780
  };
781
781
  }
782
- function S() {
782
+ function A() {
783
783
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
784
784
  }
785
785
  var H = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(H || {});
786
786
  const J = O(
787
- A(
787
+ S(
788
788
  async (e) => {
789
- const t = (e?.markets || [L.main]).map((a) => P(a)), r = U(e), o = F(
789
+ const t = (e?.markets || [L.main]).map((a) => P(a)), r = M(e), o = F(
790
790
  `/navi/pools?env=${e?.env || "prod"}&sdk=${V.version}&market=${t.map(
791
791
  (a) => a.key
792
792
  )}`,
@@ -795,16 +795,16 @@ const J = O(
795
795
  (a) => a.json()
796
796
  );
797
797
  return n.data.forEach((a) => {
798
- const i = n.meta.emodes.filter((w) => {
799
- const k = P(w.marketId);
800
- return a.market === k.key && w.isActive;
801
- }).filter((w) => !!w.assets.find((k) => k.assetId === a.id));
798
+ const i = n.meta.emodes.filter((b) => {
799
+ const j = P(b.marketId);
800
+ return a.market === j.key && b.isActive;
801
+ }).filter((b) => !!b.assets.find((j) => j.assetId === a.id));
802
802
  a.emodes = i;
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(), b = p(u).multipliedBy(a.oracle.price).toString(), g = p(a.supplyCapCeiling).shiftedBy(-27).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), y = p.max(
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(), g = p(a.supplyCapCeiling).shiftedBy(-27).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), y = p.max(
804
804
  p(a.borrowedAmount),
805
805
  p(a.validBorrowAmount)
806
806
  ).shiftedBy(-9).decimalPlaces(a.token.decimals, p.ROUND_DOWN).toString(), d = p(g).multipliedBy(a.oracle.price).toString(), f = p(y).multipliedBy(a.oracle.price).toString();
807
- a.poolSupplyAmount = s, a.poolBorrowAmount = u, a.poolSupplyValue = m, a.poolBorrowValue = b, a.poolSupplyCapAmount = g, a.poolBorrowCapAmount = y, a.poolSupplyCapValue = d, a.poolBorrowCapValue = f;
807
+ a.poolSupplyAmount = s, a.poolBorrowAmount = u, a.poolSupplyValue = m, a.poolBorrowValue = w, a.poolSupplyCapAmount = g, a.poolBorrowCapAmount = y, a.poolSupplyCapValue = d, a.poolBorrowCapValue = f;
808
808
  }), n.data;
809
809
  }
810
810
  )
@@ -812,7 +812,7 @@ const J = O(
812
812
  async function E(e, t) {
813
813
  let r = t?.market;
814
814
  if (typeof e == "string") {
815
- const a = wt(e);
815
+ const a = vt(e);
816
816
  a && (r = a.marketKey, e = a.poolId);
817
817
  }
818
818
  const o = await J({
@@ -827,24 +827,24 @@ async function E(e, t) {
827
827
  throw new Error("Pool not found");
828
828
  return n.isDeprecated && console.log(`The lending pool for coinType ${n.suiCoinType} is going to be deprecated.`), n;
829
829
  }
830
- const Zt = O(
831
- A(async (e) => {
832
- const t = U(e), r = F(`/navi/stats?sdk=${V.version}`, e);
830
+ const Xt = O(
831
+ S(async (e) => {
832
+ const t = M(e), r = F(`/navi/stats?sdk=${V.version}`, e);
833
833
  return (await fetch(r, {
834
834
  headers: N(R, t)
835
835
  }).then((n) => n.json())).data;
836
836
  })
837
- ), Xt = O(
838
- A(
837
+ ), xt = O(
838
+ S(
839
839
  async (e) => {
840
- const t = U(e), r = F(`/navi/fee?sdk=${V.version}`, e);
840
+ const t = M(e), r = F(`/navi/fee?sdk=${V.version}`, e);
841
841
  return await fetch(r, {
842
842
  headers: N(R, t)
843
843
  }).then((n) => n.json());
844
844
  }
845
845
  )
846
846
  );
847
- async function vt(e, t, r, o) {
847
+ async function Ct(e, t, r, o) {
848
848
  const n = await I({
849
849
  ...o,
850
850
  cacheTime: v
@@ -892,7 +892,7 @@ async function vt(e, t, r, o) {
892
892
  arguments: [e.object(a.contract.pool), e.object("0x05")]
893
893
  }), e;
894
894
  }
895
- async function xt(e, t, r, o) {
895
+ async function er(e, t, r, o) {
896
896
  const n = await I({
897
897
  ...o,
898
898
  cacheTime: v
@@ -975,7 +975,7 @@ async function xt(e, t, r, o) {
975
975
  typeArguments: [a.suiCoinType]
976
976
  });
977
977
  }
978
- async function er(e, t, r, o) {
978
+ async function tr(e, t, r, o) {
979
979
  const n = await I({
980
980
  ...o,
981
981
  cacheTime: v
@@ -1061,7 +1061,7 @@ async function er(e, t, r, o) {
1061
1061
  typeArguments: [a.suiCoinType]
1062
1062
  });
1063
1063
  }
1064
- async function tr(e, t, r, o) {
1064
+ async function rr(e, t, r, o) {
1065
1065
  const n = await I({
1066
1066
  ...o,
1067
1067
  cacheTime: v
@@ -1114,12 +1114,12 @@ async function tr(e, t, r, o) {
1114
1114
  typeArguments: [a.suiCoinType]
1115
1115
  }), e;
1116
1116
  }
1117
- const rr = O(
1118
- A(
1117
+ const nr = O(
1118
+ S(
1119
1119
  async (e) => {
1120
1120
  const t = await I({
1121
1121
  ...e
1122
- }), r = e?.client ?? M;
1122
+ }), r = e?.client ?? U;
1123
1123
  if (e?.address && typeof e?.asset < "u")
1124
1124
  try {
1125
1125
  const a = await E(e.asset, e), c = new q();
@@ -1144,7 +1144,7 @@ const rr = O(
1144
1144
  a
1145
1145
  );
1146
1146
  }
1147
- const n = (await yt(r, {
1147
+ const n = (await gt(r, {
1148
1148
  id: t.incentiveV3,
1149
1149
  options: { showType: !0, showOwner: !0, showContent: !0 }
1150
1150
  })).data.content.fields.borrow_fee_rate;
@@ -1171,39 +1171,39 @@ const rr = O(
1171
1171
  id: 3,
1172
1172
  key: "sui-eco",
1173
1173
  name: "Sui Eco Market"
1174
- },
1175
- "sui-usdc": {
1176
- id: 4,
1177
- key: "sui-usdc",
1178
- name: "SUI/USDC Market"
1179
- },
1180
- "wbtc-usdc": {
1181
- id: 5,
1182
- key: "wbtc-usdc",
1183
- name: "WBTC/USDC Market"
1184
- },
1185
- "xbtc-usdc": {
1186
- id: 6,
1187
- key: "xbtc-usdc",
1188
- name: "xBTC/USDC Market"
1189
- },
1190
- "vsui-usdc": {
1191
- id: 7,
1192
- key: "vsui-usdc",
1193
- name: "vSUI/USDC Market"
1194
- },
1195
- "vsui-sui": {
1196
- id: 8,
1197
- key: "vsui-sui",
1198
- name: "vSUI/SUI Market"
1199
- },
1200
- "hasui-sui": {
1201
- id: 9,
1202
- key: "hasui-sui",
1203
- name: "hasSUI/SUI Market"
1204
1174
  }
1175
+ // 'sui-usdc': {
1176
+ // id: 4,
1177
+ // key: 'sui-usdc',
1178
+ // name: 'SUI/USDC Market'
1179
+ // },
1180
+ // 'wbtc-usdc': {
1181
+ // id: 5,
1182
+ // key: 'wbtc-usdc',
1183
+ // name: 'WBTC/USDC Market'
1184
+ // },
1185
+ // 'xbtc-usdc': {
1186
+ // id: 6,
1187
+ // key: 'xbtc-usdc',
1188
+ // name: 'xBTC/USDC Market'
1189
+ // },
1190
+ // 'vsui-usdc': {
1191
+ // id: 7,
1192
+ // key: 'vsui-usdc',
1193
+ // name: 'vSUI/USDC Market'
1194
+ // },
1195
+ // 'vsui-sui': {
1196
+ // id: 8,
1197
+ // key: 'vsui-sui',
1198
+ // name: 'vSUI/SUI Market'
1199
+ // },
1200
+ // 'hasui-sui': {
1201
+ // id: 9,
1202
+ // key: 'hasui-sui',
1203
+ // name: 'hasSUI/SUI Market'
1204
+ // }
1205
1205
  };
1206
- class Ct {
1206
+ class jt {
1207
1207
  constructor(t, r) {
1208
1208
  this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
1209
1209
  marketTotalSupplyValue: "0",
@@ -1222,10 +1222,10 @@ class Ct {
1222
1222
  return;
1223
1223
  }
1224
1224
  r[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((m) => {
1225
- o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((b) => {
1226
- b.isDebt && m.assets.find(
1225
+ o[m.uniqueId] || this.emodes.push(m), m.assets.forEach((w) => {
1226
+ w.isDebt && m.assets.find(
1227
1227
  (y) => y.isCollateral && y.ltv > 0 && y.assetId !== s.id
1228
- ) && n.add(s.uniqueId), b.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== s.id) && a.add(s.uniqueId);
1228
+ ) && n.add(s.uniqueId), w.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== s.id) && a.add(s.uniqueId);
1229
1229
  });
1230
1230
  }), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
1231
1231
  }), this.poolMap = ne(this.pools, "id"), this.emodeMap = fe(this.emodes, "emodeId"), this.emodes.forEach((s) => {
@@ -1271,8 +1271,8 @@ const P = (e) => {
1271
1271
  if (!r)
1272
1272
  throw new Error("Market not found");
1273
1273
  return r;
1274
- }, kt = O(
1275
- A(
1274
+ }, It = O(
1275
+ S(
1276
1276
  async (e, t) => {
1277
1277
  const r = await J({
1278
1278
  cacheTime: 6e4,
@@ -1281,18 +1281,18 @@ const P = (e) => {
1281
1281
  });
1282
1282
  return e.map((o) => {
1283
1283
  const n = P(o), a = r.filter((c) => c.market === n.key);
1284
- return new Ct(o, a);
1284
+ return new jt(o, a);
1285
1285
  });
1286
1286
  }
1287
1287
  )
1288
- ), nr = O(
1289
- A(
1290
- async (e, t) => (await kt([e], t))[0]
1288
+ ), or = O(
1289
+ S(
1290
+ async (e, t) => (await It([e], t))[0]
1291
1291
  )
1292
1292
  ), I = O(
1293
- A(
1293
+ S(
1294
1294
  async (e) => {
1295
- const t = P(e?.market || z), r = U(e), o = F(
1295
+ const t = P(e?.market || z), r = M(e), o = F(
1296
1296
  `/navi/config?env=${e?.env || "prod"}&sdk=${V.version}&market=${t.key}`,
1297
1297
  e
1298
1298
  );
@@ -1302,7 +1302,7 @@ const P = (e) => {
1302
1302
  }
1303
1303
  )
1304
1304
  ), v = 1e3 * 60 * 5;
1305
- async function It(e, t) {
1305
+ async function kt(e, t) {
1306
1306
  const r = await I({
1307
1307
  cacheTime: v,
1308
1308
  ...t
@@ -1312,7 +1312,7 @@ async function It(e, t) {
1312
1312
  arguments: []
1313
1313
  });
1314
1314
  }
1315
- async function jt(e, t, r) {
1315
+ async function _t(e, t, r) {
1316
1316
  const o = await I({
1317
1317
  cacheTime: v,
1318
1318
  ...r
@@ -1322,7 +1322,7 @@ async function jt(e, t, r) {
1322
1322
  arguments: [t]
1323
1323
  });
1324
1324
  }
1325
- async function _t(e, t, r) {
1325
+ async function Tt(e, t, r) {
1326
1326
  const o = await I({
1327
1327
  ...r,
1328
1328
  cacheTime: v
@@ -1339,7 +1339,7 @@ async function _t(e, t, r) {
1339
1339
  arguments: [e.object(o.storage), h(t, e.pure.u64)]
1340
1340
  }), e;
1341
1341
  }
1342
- async function or(e, t) {
1342
+ async function ar(e, t) {
1343
1343
  const r = await I({
1344
1344
  ...t,
1345
1345
  cacheTime: v
@@ -1352,16 +1352,16 @@ async function or(e, t) {
1352
1352
  arguments: [e.object(r.storage)]
1353
1353
  }), e;
1354
1354
  }
1355
- async function ar(e, t, r) {
1355
+ async function ir(e, t, r) {
1356
1356
  const o = await I({
1357
1357
  cacheTime: v,
1358
1358
  ...r
1359
- }), n = await It(e, r);
1360
- await _t(e, t, {
1359
+ }), n = await kt(e, r);
1360
+ await Tt(e, t, {
1361
1361
  ...r,
1362
1362
  accountCap: n
1363
1363
  });
1364
- const a = await P(r?.market || z), c = await jt(e, n, r);
1364
+ const a = await P(r?.market || z), c = await _t(e, n, r);
1365
1365
  return e.moveCall({
1366
1366
  target: `${o.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
1367
1367
  arguments: [
@@ -1373,12 +1373,12 @@ async function ar(e, t, r) {
1373
1373
  }), n;
1374
1374
  }
1375
1375
  const Se = O(
1376
- A(
1376
+ S(
1377
1377
  async (e, t) => {
1378
1378
  const r = await I({
1379
1379
  cacheTime: v,
1380
1380
  ...t
1381
- }), o = new q(), n = t?.client ?? M;
1381
+ }), o = new q(), n = t?.client ?? U;
1382
1382
  o.moveCall({
1383
1383
  target: `${r.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
1384
1384
  arguments: [o.object(r.emode.contract.registryObject), o.pure.address(e)]
@@ -1387,29 +1387,29 @@ const Se = O(
1387
1387
  transactionBlock: o,
1388
1388
  sender: e
1389
1389
  })).results[0].returnValues, i = l.vector(l.u64()).parse(Uint8Array.from(c[0][0])), s = l.vector(l.u64()).parse(Uint8Array.from(c[1][0])), u = l.vector(l.Address).parse(Uint8Array.from(c[2][0]));
1390
- return i.map((m, b) => ({
1390
+ return i.map((m, w) => ({
1391
1391
  marketId: Number(m),
1392
- emodeId: Number(s[b]),
1393
- accountCap: u[b].toString()
1392
+ emodeId: Number(s[w]),
1393
+ accountCap: u[w].toString()
1394
1394
  }));
1395
1395
  }
1396
1396
  )
1397
1397
  );
1398
- function ir(e) {
1398
+ function cr(e) {
1399
1399
  return `${P(e.marketId).key}-${e.emodeId}`;
1400
1400
  }
1401
- function Tt(e, t) {
1401
+ function Bt(e, t) {
1402
1402
  return e.coinType ? e.coinType : t || (typeof e.type == "string" ? e.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
1403
1403
  }
1404
1404
  function ye(e, t) {
1405
- const r = Tt(e, t), o = e.coinObjectId ?? e.objectId;
1405
+ const r = Bt(e, t), o = e.coinObjectId ?? e.objectId;
1406
1406
  return !r || !o || e.balance === void 0 || e.balance === null ? null : {
1407
1407
  ...e,
1408
1408
  coinType: C(r),
1409
1409
  coinObjectId: o
1410
1410
  };
1411
1411
  }
1412
- function cr(e, t, r) {
1412
+ function sr(e, t, r) {
1413
1413
  const o = typeof r?.balance == "number", n = o ? r.balance : 0, a = BigInt(r?.addressBalance ?? 0);
1414
1414
  let c = 0;
1415
1415
  const i = [];
@@ -1429,14 +1429,14 @@ function cr(e, t, r) {
1429
1429
  } catch {
1430
1430
  return !1;
1431
1431
  }
1432
- })(s || m || "") && !!r?.useGasCoin, d = BigInt(n), f = !y && !!m, w = f ? a : 0n, k = u + w, _ = !o || u >= d ? 0n : d - u, j = f && _ > 0n && w >= _;
1433
- if (o && k < d)
1434
- throw new Error(`Balance is less than the specified balance: ${k} < ${d}`);
1435
- if (i.length === 0 && !j)
1432
+ })(s || m || "") && !!r?.useGasCoin, d = BigInt(n), f = !y && !!m, b = f ? a : 0n, j = u + b, _ = !o || u >= d ? 0n : d - u, k = f && _ > 0n && b >= _;
1433
+ if (o && j < d)
1434
+ throw new Error(`Balance is less than the specified balance: ${j} < ${d}`);
1435
+ if (i.length === 0 && !k)
1436
1436
  throw new Error("No coins to merge");
1437
1437
  if (y)
1438
1438
  return o ? e.splitCoins(e.gas, [e.pure.u64(n)]) : e.gas;
1439
- if (!j)
1439
+ if (!k)
1440
1440
  return i.length === 1 ? e.object(i[0]) : e.mergeCoins(i[0], i.slice(1)), o ? e.splitCoins(i[0], [e.pure.u64(n)]) : i[0];
1441
1441
  const T = e.moveCall({
1442
1442
  target: "0x2::coin::redeem_funds",
@@ -1454,7 +1454,7 @@ function cr(e, t, r) {
1454
1454
  $ = T;
1455
1455
  return D.length > 0 && e.mergeCoins($, D), i.length === 0 ? $ : o ? e.splitCoins($, [e.pure.u64(n)]) : $;
1456
1456
  }
1457
- async function Ae(e, t, r, o, n, a, c) {
1457
+ async function $e(e, t, r, o, n, a, c) {
1458
1458
  const i = await I({
1459
1459
  ...c,
1460
1460
  cacheTime: v
@@ -1465,7 +1465,7 @@ async function Ae(e, t, r, o, n, a, c) {
1465
1465
  e.object("0x06"),
1466
1466
  e.object(i.storage),
1467
1467
  e.object(i.oracle.priceOracle),
1468
- ht(e, s),
1468
+ wt(e, s),
1469
1469
  h(t, e.pure.address),
1470
1470
  h(s.id, e.pure.u8),
1471
1471
  h(o, e.pure.u64),
@@ -1475,11 +1475,11 @@ async function Ae(e, t, r, o, n, a, c) {
1475
1475
  typeArguments: [s.suiCoinType]
1476
1476
  });
1477
1477
  }
1478
- async function Bt(e, t, r) {
1479
- return Ae(e, t, 0, 0, 0, !1, r);
1478
+ async function Pt(e, t, r) {
1479
+ return $e(e, t, 0, 0, 0, !1, r);
1480
1480
  }
1481
- async function $e(e, t, r) {
1482
- const o = new q(), n = r?.client ?? M, a = await J({
1481
+ async function Ee(e, t, r) {
1482
+ const o = new q(), n = r?.client ?? U, a = await J({
1483
1483
  ...r,
1484
1484
  markets: Object.values(L)
1485
1485
  }), c = ne(a), s = Array.from(new Set(t.map((d) => d.market))).map((d) => P(d));
@@ -1508,64 +1508,64 @@ async function $e(e, t, r) {
1508
1508
  const m = (await W(n, {
1509
1509
  transactionBlock: o,
1510
1510
  sender: e
1511
- })).results || [], b = {};
1511
+ })).results || [], w = {};
1512
1512
  s.forEach((d, f) => {
1513
1513
  try {
1514
- const w = m[f]?.returnValues?.map((_) => l.vector(qe).parse(Uint8Array.from(_[0])))[0] || [], k = {};
1515
- for (const _ of w)
1516
- k[_.id] = {
1514
+ const b = m[f]?.returnValues?.map((_) => l.vector(ze).parse(Uint8Array.from(_[0])))[0] || [], j = {};
1515
+ for (const _ of b)
1516
+ j[_.id] = {
1517
1517
  supplyIndex: _.supply_index,
1518
1518
  borrowIndex: _.borrow_index
1519
1519
  };
1520
- b[d.key] = k;
1521
- } catch (w) {
1520
+ w[d.key] = j;
1521
+ } catch (b) {
1522
1522
  console.warn(
1523
1523
  `[@naviprotocol/lending] Failed to decode reserve data for market "${d.key}", falling back to open-api pool indices`,
1524
- w
1524
+ b
1525
1525
  );
1526
1526
  }
1527
1527
  });
1528
- const g = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(ze).parse(Uint8Array.from(f[0])))[0] || []), y = [];
1528
+ const g = m.slice(s.length).map((d) => d.returnValues?.map((f) => l.vector(Ge).parse(Uint8Array.from(f[0])))[0] || []), y = [];
1529
1529
  return g.forEach((d, f) => {
1530
- const w = t[f], k = P(w.market), _ = b[k.key] || {};
1531
- d.forEach((j) => {
1532
- if (j.supply_balance === "0" && j.borrow_balance === "0" && (w.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
1530
+ const b = t[f], j = P(b.market), _ = w[j.key] || {};
1531
+ d.forEach((k) => {
1532
+ if (k.supply_balance === "0" && k.borrow_balance === "0" && (b.emodeId === void 0 || !r?.includeZeroBalanceEmodePositions))
1533
1533
  return;
1534
- const T = c[`${k.key}-${j.asset_id}`];
1534
+ const T = c[`${j.key}-${k.asset_id}`];
1535
1535
  if (!T)
1536
1536
  return;
1537
- const $ = _[j.asset_id], D = $?.supplyIndex ?? T.currentSupplyIndex, B = $?.borrowIndex ?? T.currentBorrowIndex, X = me(j.supply_balance, D).toString(), Ve = me(j.borrow_balance, B).toString();
1537
+ const $ = _[k.asset_id], D = $?.supplyIndex ?? T.currentSupplyIndex, B = $?.borrowIndex ?? T.currentBorrowIndex, X = me(k.supply_balance, D).toString(), Me = me(k.borrow_balance, B).toString();
1538
1538
  y.push({
1539
1539
  supplyBalance: X,
1540
- borrowBalance: Ve,
1541
- assetId: j.asset_id,
1542
- market: k.key,
1540
+ borrowBalance: Me,
1541
+ assetId: k.asset_id,
1542
+ market: j.key,
1543
1543
  pool: T,
1544
- emodeId: w.emodeId
1544
+ emodeId: b.emodeId
1545
1545
  });
1546
1546
  });
1547
1547
  }), y;
1548
1548
  }
1549
- const sr = O(
1549
+ const ur = O(
1550
1550
  async (e, t) => {
1551
1551
  const o = (t?.markets || Object.keys(L)).map((n) => P(n)).map((n) => ({
1552
1552
  address: e,
1553
1553
  market: n.key
1554
1554
  }));
1555
- return await $e(e, o, t);
1555
+ return await Ee(e, o, t);
1556
1556
  }
1557
1557
  );
1558
- async function ur(e, t) {
1559
- const r = t?.client ?? M, o = new q();
1560
- await Bt(o, e, t);
1558
+ async function lr(e, t) {
1559
+ const r = t?.client ?? U, o = new q();
1560
+ await Pt(o, e, t);
1561
1561
  const n = await W(r, {
1562
1562
  transactionBlock: o,
1563
1563
  sender: e
1564
1564
  }), a = Z(n, [l.u256()]);
1565
- return Pe(Number(a[0]) || 0);
1565
+ return Ae(Number(a[0]) || 0);
1566
1566
  }
1567
- async function lr(e, t, r, o) {
1568
- const n = o?.client ?? M, a = new q();
1567
+ async function dr(e, t, r, o) {
1568
+ const n = o?.client ?? U, a = new q();
1569
1569
  let c = 0, i = 0;
1570
1570
  const s = await E(t, o);
1571
1571
  if (r.forEach((g) => {
@@ -1573,7 +1573,7 @@ async function lr(e, t, r, o) {
1573
1573
  }), c * i < 0)
1574
1574
  throw new Error("Invalid operations");
1575
1575
  const u = c > 0 || i > 0;
1576
- await Ae(
1576
+ await $e(
1577
1577
  a,
1578
1578
  e,
1579
1579
  s,
@@ -1585,14 +1585,14 @@ async function lr(e, t, r, o) {
1585
1585
  const m = await W(n, {
1586
1586
  transactionBlock: a,
1587
1587
  sender: e
1588
- }), b = Z(m, [l.u256()]);
1589
- return Pe(Number(b[0]) || 0);
1588
+ }), w = Z(m, [l.u256()]);
1589
+ return Ae(Number(w[0]) || 0);
1590
1590
  }
1591
- const dr = A(
1591
+ const pr = S(
1592
1592
  async (e, t) => {
1593
1593
  const r = new URLSearchParams();
1594
1594
  t?.cursor && r.set("cursor", t.cursor), r.set("userAddress", e);
1595
- const o = U(t), n = F(
1595
+ const o = M(t), n = F(
1596
1596
  `/navi/user/transactions?${r.toString()}&sdk=${V.version}`,
1597
1597
  t
1598
1598
  );
@@ -1601,9 +1601,9 @@ const dr = A(
1601
1601
  }).then((c) => c.json())).data;
1602
1602
  }
1603
1603
  );
1604
- async function pr(e, t) {
1604
+ async function mr(e, t) {
1605
1605
  let r = null;
1606
- const o = [], n = t?.client ?? M, a = n.core;
1606
+ const o = [], n = t?.client ?? U, a = n.core;
1607
1607
  do {
1608
1608
  let c;
1609
1609
  if (t?.coinType)
@@ -1645,15 +1645,15 @@ async function pr(e, t) {
1645
1645
  for (const u of i) {
1646
1646
  let m = null;
1647
1647
  do {
1648
- const b = await a.listCoins({
1648
+ const w = await a.listCoins({
1649
1649
  owner: e,
1650
1650
  coinType: u,
1651
1651
  cursor: m,
1652
1652
  limit: 100
1653
1653
  });
1654
1654
  o.push(
1655
- ...(b.objects ?? b.data ?? []).map((g) => ye(g, u)).filter(Boolean)
1656
- ), m = b.cursor ?? b.nextCursor ?? null;
1655
+ ...(w.objects ?? w.data ?? []).map((g) => ye(g, u)).filter(Boolean)
1656
+ ), m = w.cursor ?? w.nextCursor ?? null;
1657
1657
  } while (m);
1658
1658
  }
1659
1659
  break;
@@ -1674,7 +1674,7 @@ async function pr(e, t) {
1674
1674
  } while (r);
1675
1675
  return o;
1676
1676
  }
1677
- const Pt = O(
1677
+ const At = O(
1678
1678
  async (e, t) => {
1679
1679
  const r = [], o = (t?.markets || Object.keys(L)).map((i) => P(i)), n = await Se(e, t), a = o.map((i) => ({
1680
1680
  address: e,
@@ -1686,7 +1686,7 @@ const Pt = O(
1686
1686
  emodeId: i.emodeId
1687
1687
  }))
1688
1688
  );
1689
- return (await $e(e, a, t)).forEach((i) => {
1689
+ return (await Ee(e, a, t)).forEach((i) => {
1690
1690
  const s = typeof i.emodeId == "number" ? n.find((u) => {
1691
1691
  const m = P(i.market);
1692
1692
  return u.emodeId === i.emodeId && u.marketId === m.id;
@@ -1695,11 +1695,11 @@ const Pt = O(
1695
1695
  if (!i.pool.emodes.find((m) => m.emodeId === s.emodeId))
1696
1696
  return;
1697
1697
  if (p(i.supplyBalance).gte(0)) {
1698
- const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), b = K(i.pool, s);
1699
- if (m.gt(0) || b.emode.isCollateral)
1698
+ const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), w = K(i.pool, s);
1699
+ if (m.gt(0) || w.emode.isCollateral)
1700
1700
  try {
1701
1701
  r.push({
1702
- id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${S()}`,
1702
+ id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${A()}`,
1703
1703
  wallet: e,
1704
1704
  protocol: "navi",
1705
1705
  market: i.market,
@@ -1717,11 +1717,11 @@ const Pt = O(
1717
1717
  }
1718
1718
  }
1719
1719
  if (p(i.borrowBalance).gte(0)) {
1720
- const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), b = K(i.pool, s);
1721
- if (m.gt(0) || b.emode.isDebt)
1720
+ const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), w = K(i.pool, s);
1721
+ if (m.gt(0) || w.emode.isDebt)
1722
1722
  try {
1723
1723
  r.push({
1724
- id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${S()}`,
1724
+ id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${A()}`,
1725
1725
  wallet: e,
1726
1726
  protocol: "navi",
1727
1727
  market: i.market,
@@ -1742,7 +1742,7 @@ const Pt = O(
1742
1742
  if (p(i.supplyBalance).gt(0)) {
1743
1743
  const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1744
1744
  r.push({
1745
- id: `${i.pool.uniqueId}_navi-lending-supply-${S()}`,
1745
+ id: `${i.pool.uniqueId}_navi-lending-supply-${A()}`,
1746
1746
  wallet: e,
1747
1747
  protocol: "navi",
1748
1748
  type: "navi-lending-supply",
@@ -1758,7 +1758,7 @@ const Pt = O(
1758
1758
  if (p(i.borrowBalance).gt(0)) {
1759
1759
  const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1760
1760
  r.push({
1761
- id: `${i.pool.uniqueId}_navi-lending-borrow-${S()}`,
1761
+ id: `${i.pool.uniqueId}_navi-lending-borrow-${A()}`,
1762
1762
  wallet: e,
1763
1763
  protocol: "navi",
1764
1764
  market: i.market,
@@ -1827,7 +1827,7 @@ class G {
1827
1827
  const o = !!t.isEMode, n = this.getPrice(t);
1828
1828
  let a;
1829
1829
  return o ? a = {
1830
- id: S(),
1830
+ id: A(),
1831
1831
  wallet: "",
1832
1832
  protocol: "navi",
1833
1833
  market: "",
@@ -1840,7 +1840,7 @@ class G {
1840
1840
  emodeCap: {}
1841
1841
  }
1842
1842
  } : a = {
1843
- id: S(),
1843
+ id: A(),
1844
1844
  wallet: "",
1845
1845
  protocol: "navi",
1846
1846
  market: "",
@@ -1857,7 +1857,7 @@ class G {
1857
1857
  const o = !!t.isEMode, n = this.getPrice(t);
1858
1858
  let a;
1859
1859
  return o ? a = {
1860
- id: S(),
1860
+ id: A(),
1861
1861
  wallet: "",
1862
1862
  protocol: "navi",
1863
1863
  market: "",
@@ -1870,7 +1870,7 @@ class G {
1870
1870
  emodeCap: {}
1871
1871
  }
1872
1872
  } : a = {
1873
- id: S(),
1873
+ id: A(),
1874
1874
  wallet: "",
1875
1875
  protocol: "navi",
1876
1876
  market: "",
@@ -1887,7 +1887,7 @@ class G {
1887
1887
  const o = !!t.isEMode, n = this.getPrice(t);
1888
1888
  let a;
1889
1889
  return o ? a = {
1890
- id: S(),
1890
+ id: A(),
1891
1891
  wallet: "",
1892
1892
  protocol: "navi",
1893
1893
  market: "",
@@ -1900,7 +1900,7 @@ class G {
1900
1900
  emodeCap: {}
1901
1901
  }
1902
1902
  } : a = {
1903
- id: S(),
1903
+ id: A(),
1904
1904
  wallet: "",
1905
1905
  protocol: "navi",
1906
1906
  market: "",
@@ -1917,7 +1917,7 @@ class G {
1917
1917
  const o = !!t.isEMode, n = this.getPrice(t);
1918
1918
  let a;
1919
1919
  return o ? a = {
1920
- id: S(),
1920
+ id: A(),
1921
1921
  wallet: "",
1922
1922
  protocol: "navi",
1923
1923
  market: "",
@@ -1930,7 +1930,7 @@ class G {
1930
1930
  emodeCap: {}
1931
1931
  }
1932
1932
  } : a = {
1933
- id: S(),
1933
+ id: A(),
1934
1934
  wallet: "",
1935
1935
  protocol: "navi",
1936
1936
  market: "",
@@ -1963,11 +1963,11 @@ class G {
1963
1963
  } else if (y.type === "navi-lending-emode-supply") {
1964
1964
  const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d);
1965
1965
  n = n.plus(f);
1966
- const w = d.pool.emode;
1966
+ const b = d.pool.emode;
1967
1967
  s = s.plus(
1968
- new p(f).multipliedBy(w.lt)
1968
+ new p(f).multipliedBy(b.lt)
1969
1969
  ), u = u.plus(
1970
- new p(f).multipliedBy(w.ltv)
1970
+ new p(f).multipliedBy(b.ltv)
1971
1971
  );
1972
1972
  } else if (y.type === "navi-lending-emode-borrow") {
1973
1973
  const d = y["navi-lending-emode-borrow"];
@@ -1975,32 +1975,32 @@ class G {
1975
1975
  }
1976
1976
  }), a = p.max(a, 0), n = p.max(n, 0), s = p.max(s, 0), u = p.max(u, 0), t.forEach((y) => {
1977
1977
  if (y.type === "navi-lending-supply") {
1978
- const d = y["navi-lending-supply"], f = this.resolveValueUSD(d), w = d.pool.supplyIncentiveApyInfo.apy;
1978
+ const d = y["navi-lending-supply"], f = this.resolveValueUSD(d), b = d.pool.supplyIncentiveApyInfo.apy;
1979
1979
  n.gt(0) && (c = c.plus(
1980
- new p(f).dividedBy(n).multipliedBy(new p(w).dividedBy(100))
1980
+ new p(f).dividedBy(n).multipliedBy(new p(b).dividedBy(100))
1981
1981
  )), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1982
1982
  } else if (y.type === "navi-lending-borrow") {
1983
- const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d), w = d.pool.borrowIncentiveApyInfo.apy;
1983
+ const d = y["navi-lending-borrow"], f = this.resolveValueUSD(d), b = d.pool.borrowIncentiveApyInfo.apy;
1984
1984
  a.gt(0) && (i = i.plus(
1985
- new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1985
+ new p(f).dividedBy(a).multipliedBy(new p(b).dividedBy(100))
1986
1986
  )), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1987
1987
  } else if (y.type === "navi-lending-emode-supply") {
1988
- const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d), w = d.pool.supplyIncentiveApyInfo.apy;
1988
+ const d = y["navi-lending-emode-supply"], f = this.resolveValueUSD(d), b = d.pool.supplyIncentiveApyInfo.apy;
1989
1989
  n.gt(0) && (c = c.plus(
1990
- new p(f).dividedBy(n).multipliedBy(new p(w).dividedBy(100))
1990
+ new p(f).dividedBy(n).multipliedBy(new p(b).dividedBy(100))
1991
1991
  )), r[d.pool.suiCoinType] = p(r[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1992
1992
  } else if (y.type === "navi-lending-emode-borrow") {
1993
- const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d), w = d.pool.borrowIncentiveApyInfo.apy;
1993
+ const d = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(d), b = d.pool.borrowIncentiveApyInfo.apy;
1994
1994
  a.gt(0) && (i = i.plus(
1995
- new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1995
+ new p(f).dividedBy(a).multipliedBy(new p(b).dividedBy(100))
1996
1996
  )), o[d.pool.suiCoinType] = p(o[d.pool.suiCoinType] || 0).plus(d.amount).toString();
1997
1997
  }
1998
1998
  });
1999
- const m = n.minus(a), b = n.minus(a).eq(0) ? new p(0) : n.multipliedBy(c).minus(a.multipliedBy(i)).div(n.minus(a));
1999
+ const m = n.minus(a), w = n.minus(a).eq(0) ? new p(0) : n.multipliedBy(c).minus(a.multipliedBy(i)).div(n.minus(a));
2000
2000
  return {
2001
2001
  hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
2002
2002
  netVaule: m.toString(),
2003
- netWorthApr: b.toString(),
2003
+ netWorthApr: w.toString(),
2004
2004
  totalSupplyValue: n.toString(),
2005
2005
  totalBorrowValue: a.toString(),
2006
2006
  totalsupplyApy: c.toString(),
@@ -2012,7 +2012,7 @@ class G {
2012
2012
  };
2013
2013
  }
2014
2014
  }
2015
- async function mr(e, t, r, o) {
2015
+ async function fr(e, t, r, o) {
2016
2016
  const n = await I({
2017
2017
  ...o,
2018
2018
  cacheTime: v
@@ -2028,33 +2028,37 @@ async function mr(e, t, r, o) {
2028
2028
  ]
2029
2029
  });
2030
2030
  }
2031
- const Ee = new Ie("https://hermes.pyth.network", {
2032
- timeout: 1e4
2033
- });
2034
- async function fr(e) {
2031
+ const ge = /* @__PURE__ */ new Map(), Oe = (e) => {
2032
+ const t = e ?? "https://hermes.pyth.network";
2033
+ let r = ge.get(t);
2034
+ return r || (r = new ke(t, { timeout: 1e4 }), ge.set(t, r)), r;
2035
+ };
2036
+ async function yr(e, t) {
2035
2037
  try {
2036
- const t = [], r = await Ee.getLatestPriceFeeds(e);
2037
- if (!r) return t;
2038
- const o = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
2039
- for (const n of r) {
2040
- const a = n.getPriceUnchecked();
2041
- if (a.publishTime > o) {
2038
+ const r = [], o = await I({ ...t, cacheTime: v }), n = await Oe(
2039
+ o.oracle.hermesEndpoint
2040
+ ).getLatestPriceFeeds(e);
2041
+ if (!n) return r;
2042
+ const a = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
2043
+ for (const c of n) {
2044
+ const i = c.getPriceUnchecked();
2045
+ if (i.publishTime > a) {
2042
2046
  console.warn(
2043
- `pyth price feed is invalid, id: ${n.id}, publish time: ${a.publishTime}, current timestamp: ${o}`
2047
+ `pyth price feed is invalid, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
2044
2048
  );
2045
2049
  continue;
2046
2050
  }
2047
- o - n.getPriceUnchecked().publishTime > 30 && (console.info(
2048
- `stale price feed, id: ${n.id}, publish time: ${a.publishTime}, current timestamp: ${o}`
2049
- ), t.push(n.id));
2051
+ a - c.getPriceUnchecked().publishTime > 30 && (console.info(
2052
+ `stale price feed, id: ${c.id}, publish time: ${i.publishTime}, current timestamp: ${a}`
2053
+ ), r.push(c.id));
2050
2054
  }
2051
- return t;
2052
- } catch (t) {
2053
- throw new Error(`failed to get pyth stale price feed id, msg: ${t.message}`);
2055
+ return r;
2056
+ } catch (r) {
2057
+ throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
2054
2058
  }
2055
2059
  }
2056
2060
  async function St(e, t) {
2057
- const r = [], o = t?.client ?? M, n = e.map((c) => c.priceInfoObject), a = await gt(o, {
2061
+ const r = [], o = t?.client ?? U, n = e.map((c) => c.priceInfoObject), a = await ht(o, {
2058
2062
  ids: Array.from(new Set(n)),
2059
2063
  options: { showContent: !0 }
2060
2064
  });
@@ -2074,11 +2078,11 @@ async function St(e, t) {
2074
2078
  console.warn(`unexpected pyth price struct, priceInfoObject: ${i.objectId}`);
2075
2079
  continue;
2076
2080
  }
2077
- const { magnitude: b, negative: g } = m, y = u.conf, d = u.timestamp;
2081
+ const { magnitude: w, negative: g } = m, y = u.conf, d = u.timestamp;
2078
2082
  r.push({
2079
2083
  priceFeedId: s.priceFeedId,
2080
2084
  priceInfoObject: s.priceInfoObject,
2081
- price: g ? "-" + b : b,
2085
+ price: g ? "-" + w : w,
2082
2086
  conf: y,
2083
2087
  publishTime: Number(d),
2084
2088
  expiration: s.expiration
@@ -2086,7 +2090,7 @@ async function St(e, t) {
2086
2090
  }
2087
2091
  return r;
2088
2092
  }
2089
- async function At(e, t) {
2093
+ async function $t(e, t) {
2090
2094
  try {
2091
2095
  const r = [], o = await St(e, t);
2092
2096
  if (!o) return r;
@@ -2108,14 +2112,16 @@ async function At(e, t) {
2108
2112
  throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
2109
2113
  }
2110
2114
  }
2111
- async function $t(e, t, r) {
2112
- const o = r?.client ?? M, n = await I({
2115
+ async function Et(e, t, r) {
2116
+ const o = r?.client ?? U, n = await I({
2113
2117
  ...r,
2114
2118
  cacheTime: v
2115
2119
  });
2116
2120
  try {
2117
- const a = await Ee.getPriceFeedsUpdateData(t);
2118
- return await new lt(
2121
+ const a = await Oe(
2122
+ n.oracle.hermesEndpoint
2123
+ ).getPriceFeedsUpdateData(t);
2124
+ return await new dt(
2119
2125
  o,
2120
2126
  n.oracle.pythStateId,
2121
2127
  n.oracle.wormholeStateId
@@ -2124,7 +2130,7 @@ async function $t(e, t, r) {
2124
2130
  throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
2125
2131
  }
2126
2132
  }
2127
- async function ge(e, t, r) {
2133
+ async function he(e, t, r) {
2128
2134
  const o = await I({
2129
2135
  ...r,
2130
2136
  cacheTime: v
@@ -2134,12 +2140,12 @@ async function ge(e, t, r) {
2134
2140
  priceFeedId: c.pythPriceFeedId,
2135
2141
  priceInfoObject: c.pythPriceInfoObject,
2136
2142
  expiration: 30
2137
- })), a = await At(n, r);
2138
- a.length > 0 && await $t(e, a, r);
2143
+ })), a = await $t(n, r);
2144
+ a.length > 0 && await Et(e, a, r);
2139
2145
  }
2140
2146
  for (const n of t)
2141
2147
  e.moveCall({
2142
- target: `${o.oracle.packageId}::oracle_pro::update_single_price_v2`,
2148
+ target: `${o.oracle.packageId}::oracle_pro::${o.oracle.updateFunction ?? "update_single_price_v2"}`,
2143
2149
  arguments: [
2144
2150
  e.object("0x6"),
2145
2151
  // Clock object
@@ -2158,13 +2164,13 @@ async function ge(e, t, r) {
2158
2164
  });
2159
2165
  return e;
2160
2166
  }
2161
- async function Oe(e) {
2167
+ async function Ve(e) {
2162
2168
  return (await I({
2163
2169
  ...e,
2164
2170
  cacheTime: v
2165
2171
  })).oracle.feeds;
2166
2172
  }
2167
- function Et(e, t) {
2173
+ function Ot(e, t) {
2168
2174
  return e.filter((r) => !!(t?.lendingState && t.lendingState.find((n) => r.oracleId === n.pool.oracleId) || t?.lendingPositions && t.lendingPositions.find((n) => {
2169
2175
  if (![
2170
2176
  "navi-lending-supply",
@@ -2177,23 +2183,23 @@ function Et(e, t) {
2177
2183
  return r.oracleId === c?.oracleId;
2178
2184
  }) || t?.pools && t.pools.find((n) => r.oracleId === n.oracleId)));
2179
2185
  }
2180
- async function yr(e, t, r, o) {
2186
+ async function gr(e, t, r, o) {
2181
2187
  let n;
2182
2188
  try {
2183
- const a = await Oe({
2189
+ const a = await Ve({
2184
2190
  ...o
2185
2191
  }), c = [];
2186
2192
  r.forEach((u) => {
2187
2193
  c.includes(u.market) || c.push(u.market);
2188
2194
  });
2189
- const i = await Pt(t, {
2195
+ const i = await At(t, {
2190
2196
  ...o,
2191
2197
  markets: c
2192
2198
  });
2193
- return n = Et(a, {
2199
+ return n = Ot(a, {
2194
2200
  lendingPositions: i,
2195
2201
  pools: r
2196
- }), await ge(e, n, {
2202
+ }), await he(e, n, {
2197
2203
  updatePythPriceFeeds: !0,
2198
2204
  ...o
2199
2205
  });
@@ -2202,7 +2208,7 @@ async function yr(e, t, r, o) {
2202
2208
  throw a;
2203
2209
  if (console.error(a), n)
2204
2210
  try {
2205
- return await ge(e, n, {
2211
+ return await he(e, n, {
2206
2212
  ...o,
2207
2213
  updatePythPriceFeeds: !1
2208
2214
  });
@@ -2213,9 +2219,9 @@ async function yr(e, t, r, o) {
2213
2219
  }
2214
2220
  }
2215
2221
  const ae = O(
2216
- A(
2222
+ S(
2217
2223
  async (e) => {
2218
- const t = U(e), r = F(
2224
+ const t = M(e), r = F(
2219
2225
  `/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || z}`,
2220
2226
  e
2221
2227
  ), o = await fetch(r, {
@@ -2228,10 +2234,10 @@ const ae = O(
2228
2234
  }
2229
2235
  )
2230
2236
  );
2231
- async function gr(e, t) {
2237
+ async function hr(e, t) {
2232
2238
  return (await ae(t)).find((o) => typeof e == "string" ? C(o.coinType) === C(e) : typeof e == "number" ? o.assetId === e : o.assetId === e.id) || null;
2233
2239
  }
2234
- async function hr(e, t, r, o) {
2240
+ async function wr(e, t, r, o) {
2235
2241
  const n = await I({
2236
2242
  ...o,
2237
2243
  cacheTime: v
@@ -2293,13 +2299,13 @@ async function br(e, t, r, o, n) {
2293
2299
  });
2294
2300
  return [u];
2295
2301
  }
2296
- async function wr(e, t, r, o, n, a) {
2302
+ async function vr(e, t, r, o, n, a) {
2297
2303
  const c = {
2298
2304
  ...a,
2299
2305
  cacheTime: v
2300
2306
  }, i = await I(c), s = await E(t, c), u = await E(o, c);
2301
2307
  if (i.version === 1) {
2302
- const [m, b] = e.moveCall({
2308
+ const [m, w] = e.moveCall({
2303
2309
  target: `${i.package}::incentive_v3::liquidation`,
2304
2310
  arguments: [
2305
2311
  e.object("0x06"),
@@ -2327,9 +2333,9 @@ async function wr(e, t, r, o, n, a) {
2327
2333
  ],
2328
2334
  typeArguments: [s.suiCoinType, u.suiCoinType]
2329
2335
  });
2330
- return [m, b];
2336
+ return [m, w];
2331
2337
  } else {
2332
- const [m, b] = e.moveCall({
2338
+ const [m, w] = e.moveCall({
2333
2339
  target: `${i.package}::incentive_v3::liquidation_v2`,
2334
2340
  arguments: [
2335
2341
  e.object("0x06"),
@@ -2359,15 +2365,15 @@ async function wr(e, t, r, o, n, a) {
2359
2365
  ],
2360
2366
  typeArguments: [s.suiCoinType, u.suiCoinType]
2361
2367
  });
2362
- return [m, b];
2368
+ return [m, w];
2363
2369
  }
2364
2370
  }
2365
- async function Ot(e, t, r) {
2366
- const o = r?.client ?? M, n = await J({
2371
+ async function Vt(e, t, r) {
2372
+ const o = r?.client ?? U, n = await J({
2367
2373
  ...r,
2368
2374
  markets: Object.values(L),
2369
2375
  cacheTime: v
2370
- }), a = await Oe(r), c = [];
2376
+ }), a = await Ve(r), c = [];
2371
2377
  return await Promise.all(
2372
2378
  t.map(async (i) => {
2373
2379
  try {
@@ -2389,13 +2395,13 @@ async function Ot(e, t, r) {
2389
2395
  // User address
2390
2396
  ]
2391
2397
  });
2392
- const b = (await W(o, {
2398
+ const w = (await W(o, {
2393
2399
  transactionBlock: u,
2394
2400
  sender: e
2395
2401
  }))?.results?.[0];
2396
- if (!b)
2402
+ if (!w)
2397
2403
  return;
2398
- const g = Z({ results: [b] }, [
2404
+ const g = Z({ results: [w] }, [
2399
2405
  l.vector(l.string()),
2400
2406
  // Asset coin types
2401
2407
  l.vector(l.string()),
@@ -2411,12 +2417,12 @@ async function Ot(e, t, r) {
2411
2417
  const y = g[0].length;
2412
2418
  for (let d = 0; d < y; d++) {
2413
2419
  const f = a.find(
2414
- (k) => C(k.coinType) === C(g[1][d])
2415
- ), w = n.find(
2416
- (k) => C(k.coinType) === C(g[0][d]) && k.market === i.market
2420
+ (j) => C(j.coinType) === C(g[1][d])
2421
+ ), b = n.find(
2422
+ (j) => C(j.coinType) === C(g[0][d]) && j.market === i.market
2417
2423
  );
2418
- !f || !w || c.push({
2419
- assetId: w.id,
2424
+ !f || !b || c.push({
2425
+ assetId: b.id,
2420
2426
  assetCoinType: C(g[0][d]),
2421
2427
  rewardCoinType: C(g[1][d]),
2422
2428
  option: Number(g[2][d]),
@@ -2438,7 +2444,7 @@ async function Ot(e, t, r) {
2438
2444
  })
2439
2445
  ), c;
2440
2446
  }
2441
- async function vr(e, t) {
2447
+ async function Cr(e, t) {
2442
2448
  const r = (t?.markets || [L.main]).map((a) => P(a)), o = await Se(e, t), n = r.map((a) => ({
2443
2449
  address: e,
2444
2450
  owner: e,
@@ -2454,9 +2460,9 @@ async function vr(e, t) {
2454
2460
  };
2455
2461
  })
2456
2462
  );
2457
- return await Ot(e, n, t);
2463
+ return await Vt(e, n, t);
2458
2464
  }
2459
- function Cr(e) {
2465
+ function jr(e) {
2460
2466
  const t = /* @__PURE__ */ new Map();
2461
2467
  e.forEach((o) => {
2462
2468
  const n = o.assetId, a = o.option, c = `${n}-${a}-${o.rewardCoinType}-${o.market}`;
@@ -2485,9 +2491,9 @@ function Cr(e) {
2485
2491
  }))
2486
2492
  }));
2487
2493
  }
2488
- const kr = A(
2494
+ const Ir = S(
2489
2495
  async (e, t) => {
2490
- const r = U(t), o = F(
2496
+ const r = M(t), o = F(
2491
2497
  `/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${t?.market || z}`,
2492
2498
  t
2493
2499
  );
@@ -2495,9 +2501,9 @@ const kr = A(
2495
2501
  headers: N(R, r)
2496
2502
  }).then((a) => a.json())).data;
2497
2503
  }
2498
- ), Ir = A(
2504
+ ), kr = S(
2499
2505
  async (e, t) => {
2500
- const r = U(t), o = F(
2506
+ const r = M(t), o = F(
2501
2507
  `/navi/user/rewards?userAddress=${e}&page=${t?.page || 1}&pageSize=${t?.size || 400}&sdk=${V.version}&market=${t?.market || z}`,
2502
2508
  t
2503
2509
  ), n = await fetch(o, {
@@ -2508,14 +2514,14 @@ const kr = A(
2508
2514
  });
2509
2515
  }
2510
2516
  );
2511
- async function jr(e, t, r) {
2517
+ async function _r(e, t, r) {
2512
2518
  const o = await J({
2513
2519
  ...r,
2514
2520
  markets: Object.values(L),
2515
2521
  cacheTime: v
2516
2522
  }), n = /* @__PURE__ */ new Map();
2517
2523
  for (const c of t) {
2518
- const { rewardCoinType: i, ruleIds: s, market: u, owner: m, address: b, emodeId: g } = c, y = `${i}___${b}__${u}`;
2524
+ const { rewardCoinType: i, ruleIds: s, market: u, owner: m, address: w, emodeId: g } = c, y = `${i}___${w}__${u}`;
2519
2525
  for (const d of s) {
2520
2526
  n.has(y) || n.set(y, {
2521
2527
  assetIds: [],
@@ -2523,7 +2529,7 @@ async function jr(e, t, r) {
2523
2529
  amount: 0,
2524
2530
  market: u,
2525
2531
  owner: m,
2526
- address: b,
2532
+ address: w,
2527
2533
  isEMode: typeof g < "u"
2528
2534
  });
2529
2535
  const f = n.get(y);
@@ -2533,24 +2539,24 @@ async function jr(e, t, r) {
2533
2539
  const a = [];
2534
2540
  for (const [
2535
2541
  c,
2536
- { assetIds: i, ruleIds: s, amount: u, market: m, owner: b, address: g, isEMode: y }
2542
+ { assetIds: i, ruleIds: s, amount: u, market: m, owner: w, address: g, isEMode: y }
2537
2543
  ] of n) {
2538
2544
  const d = await I({
2539
2545
  ...r,
2540
2546
  cacheTime: v,
2541
2547
  market: m
2542
- }), f = c.split("___")[0], w = o.filter(
2543
- (j) => C(j.suiCoinType) === C(f)
2548
+ }), f = c.split("___")[0], b = o.filter(
2549
+ (k) => C(k.suiCoinType) === C(f)
2544
2550
  );
2545
- w.sort((j, T) => j.market === m ? -1 : 1);
2546
- const k = w[0], _ = d.rewardFunds[C(f)];
2551
+ b.sort((k, T) => k.market === m ? -1 : 1);
2552
+ const j = b[0], _ = d.rewardFunds[C(f)];
2547
2553
  if (!_)
2548
2554
  throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
2549
2555
  if (r?.accountCap && !r.customCoinReceive)
2550
2556
  throw new Error("customCoinReceive is required when accountCap is provided");
2551
2557
  if (r?.customCoinReceive) {
2552
- let j;
2553
- r.accountCap ? j = e.moveCall({
2558
+ let k;
2559
+ r.accountCap ? k = e.moveCall({
2554
2560
  target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
2555
2561
  arguments: [
2556
2562
  e.object("0x06"),
@@ -2569,7 +2575,7 @@ async function jr(e, t, r) {
2569
2575
  // Account capability
2570
2576
  ],
2571
2577
  typeArguments: [f]
2572
- }) : y ? j = e.moveCall({
2578
+ }) : y ? k = e.moveCall({
2573
2579
  target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
2574
2580
  arguments: [
2575
2581
  e.object("0x06"),
@@ -2588,7 +2594,7 @@ async function jr(e, t, r) {
2588
2594
  // Account capability
2589
2595
  ],
2590
2596
  typeArguments: [f]
2591
- }) : j = e.moveCall({
2597
+ }) : k = e.moveCall({
2592
2598
  target: `${d.package}::incentive_v3::claim_reward`,
2593
2599
  arguments: [
2594
2600
  e.object("0x06"),
@@ -2608,7 +2614,7 @@ async function jr(e, t, r) {
2608
2614
  });
2609
2615
  const [T] = e.moveCall({
2610
2616
  target: "0x2::coin::from_balance",
2611
- arguments: [j],
2617
+ arguments: [k],
2612
2618
  typeArguments: [f]
2613
2619
  });
2614
2620
  if (r?.customCoinReceive.type === "transfer") {
@@ -2620,23 +2626,23 @@ async function jr(e, t, r) {
2620
2626
  );
2621
2627
  }
2622
2628
  if (r?.customCoinReceive.type === "depositNAVI") {
2623
- const $ = p(k.totalSupplyAmount).shiftedBy(-9), D = p(k.supplyCapCeiling).shiftedBy(-27);
2629
+ const $ = p(j.totalSupplyAmount).shiftedBy(-9), D = p(j.supplyCapCeiling).shiftedBy(-27);
2624
2630
  $.plus(u).isGreaterThan(D) && r?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
2625
2631
  [T],
2626
2632
  e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
2627
- ) : await vt(e, k, T, {
2633
+ ) : await Ct(e, j, T, {
2628
2634
  ...r,
2629
- market: k.market
2635
+ market: j.market
2630
2636
  });
2631
2637
  } else
2632
2638
  a.push({
2633
2639
  coin: T,
2634
- identifier: k,
2635
- owner: b,
2640
+ identifier: j,
2641
+ owner: w,
2636
2642
  isEMode: y
2637
2643
  });
2638
2644
  } else if (r?.accountCap || y) {
2639
- const j = e.moveCall({
2645
+ const k = e.moveCall({
2640
2646
  target: `${d.package}::incentive_v3::claim_reward_with_account_cap`,
2641
2647
  arguments: [
2642
2648
  e.object("0x06"),
@@ -2657,12 +2663,12 @@ async function jr(e, t, r) {
2657
2663
  typeArguments: [f]
2658
2664
  }), [T] = e.moveCall({
2659
2665
  target: "0x2::coin::from_balance",
2660
- arguments: [j],
2666
+ arguments: [k],
2661
2667
  typeArguments: [f]
2662
2668
  });
2663
2669
  e.transferObjects(
2664
2670
  [T],
2665
- h(r?.accountCap || b, e.pure.address)
2671
+ h(r?.accountCap || w, e.pure.address)
2666
2672
  );
2667
2673
  } else
2668
2674
  e.moveCall({
@@ -2690,84 +2696,84 @@ export {
2690
2696
  ie as Address,
2691
2697
  v as DEFAULT_CACHE_TIME,
2692
2698
  z as DEFAULT_MARKET_IDENTITY,
2693
- Wt as FlashLoanAssetConfig,
2694
- qt as IncentiveAPYInfo,
2695
- Le as IncentivePoolInfo,
2696
- zt as IncentivePoolInfoByPhase,
2699
+ Ht as FlashLoanAssetConfig,
2700
+ zt as IncentiveAPYInfo,
2701
+ qe as IncentivePoolInfo,
2702
+ Gt as IncentivePoolInfoByPhase,
2697
2703
  L as MARKETS,
2698
- Ct as Market,
2699
- Ke as NaviMissingGraphQLClientError,
2700
- Gt as OracleInfo,
2701
- et as PUBLIC_MAINNET_GRPC_URL,
2704
+ jt as Market,
2705
+ Qe as NaviMissingGraphQLClientError,
2706
+ Wt as OracleInfo,
2707
+ tt as PUBLIC_MAINNET_GRPC_URL,
2702
2708
  H as PoolOperator,
2703
- qe as ReserveDataInfo,
2704
- Ie as SuiPriceServiceConnection,
2705
- lt as SuiPythClient,
2709
+ ze as ReserveDataInfo,
2710
+ ke as SuiPriceServiceConnection,
2711
+ dt as SuiPythClient,
2706
2712
  G as UserPositions,
2707
- ze as UserStateInfo,
2708
- er as borrowCoinPTB,
2713
+ Ge as UserStateInfo,
2714
+ tr as borrowCoinPTB,
2709
2715
  F as buildNaviOpenApiUrl,
2710
- jr as claimLendingRewardsPTB,
2711
- Yt as configureNaviSdk,
2712
- It as createAccountCapPTB,
2713
- ar as createEModeCapPTB,
2714
- ke as createNaviLegacyJsonRpcClient,
2715
- rt as createNaviSuiClient,
2716
- xe as createNaviSuiClientBundle,
2717
- vt as depositCoinPTB,
2718
- ir as emodeIdentityId,
2719
- _t as enterEModePTB,
2720
- or as exitEModePTB,
2721
- Et as filterPriceFeeds,
2722
- hr as flashloanPTB,
2723
- jt as getAccountCapOwnerPTB,
2724
- Jt as getAddressBalance,
2716
+ _r as claimLendingRewardsPTB,
2717
+ Zt as configureNaviSdk,
2718
+ kt as createAccountCapPTB,
2719
+ ir as createEModeCapPTB,
2720
+ Ie as createNaviLegacyJsonRpcClient,
2721
+ nt as createNaviSuiClient,
2722
+ et as createNaviSuiClientBundle,
2723
+ Ct as depositCoinPTB,
2724
+ cr as emodeIdentityId,
2725
+ Tt as enterEModePTB,
2726
+ ar as exitEModePTB,
2727
+ Ot as filterPriceFeeds,
2728
+ wr as flashloanPTB,
2729
+ _t as getAccountCapOwnerPTB,
2730
+ Kt as getAddressBalance,
2725
2731
  ae as getAllFlashLoanAssets,
2726
- rr as getBorrowFee,
2727
- Ht as getCoinObjectOnlyBalance,
2728
- pr as getCoins,
2732
+ nr as getBorrowFee,
2733
+ Jt as getCoinObjectOnlyBalance,
2734
+ mr as getCoins,
2729
2735
  I as getConfig,
2730
- Xt as getFees,
2731
- gr as getFlashLoanAsset,
2732
- ur as getHealthFactor,
2733
- Bt as getHealthFactorPTB,
2734
- Pt as getLendingPositions,
2735
- sr as getLendingState,
2736
- nr as getMarket,
2736
+ xt as getFees,
2737
+ hr as getFlashLoanAsset,
2738
+ lr as getHealthFactor,
2739
+ Pt as getHealthFactorPTB,
2740
+ At as getLendingPositions,
2741
+ ur as getLendingState,
2742
+ or as getMarket,
2737
2743
  P as getMarketConfig,
2738
- kt as getMarkets,
2744
+ It as getMarkets,
2739
2745
  E as getPool,
2740
2746
  J as getPools,
2741
- Oe as getPriceFeeds,
2742
- fr as getPythStalePriceFeedId,
2743
- At as getPythStalePriceFeedIdV2,
2744
- lr as getSimulatedHealthFactor,
2745
- Ae as getSimulatedHealthFactorPTB,
2746
- Zt as getStats,
2747
- dr as getTransactions,
2748
- vr as getUserAvailableLendingRewards,
2749
- Ir as getUserClaimedRewardHistory,
2747
+ Ve as getPriceFeeds,
2748
+ yr as getPythStalePriceFeedId,
2749
+ $t as getPythStalePriceFeedIdV2,
2750
+ dr as getSimulatedHealthFactor,
2751
+ $e as getSimulatedHealthFactorPTB,
2752
+ Xt as getStats,
2753
+ pr as getTransactions,
2754
+ Cr as getUserAvailableLendingRewards,
2755
+ kr as getUserClaimedRewardHistory,
2750
2756
  Se as getUserEModeCaps,
2751
- kr as getUserTotalClaimedReward,
2752
- wr as liquidatePTB,
2753
- Kt as listAddressBalances,
2754
- cr as mergeCoinsPTB,
2757
+ Ir as getUserTotalClaimedReward,
2758
+ vr as liquidatePTB,
2759
+ Qt as listAddressBalances,
2760
+ sr as mergeCoinsPTB,
2755
2761
  N as mergeServiceHeaders,
2756
- Ce as normalizeAddressBalance,
2762
+ je as normalizeAddressBalance,
2757
2763
  C as normalizeCoinType,
2758
- wt as parsePoolUID,
2764
+ vt as parsePoolUID,
2759
2765
  h as parseTxValue,
2760
- tr as repayCoinPTB,
2766
+ rr as repayCoinPTB,
2761
2767
  br as repayFlashLoanPTB,
2762
- Qt as requireNaviGraphQLClient,
2763
- U as resolveNaviOpenApiEndpoint,
2764
- Cr as summaryLendingRewards,
2765
- yr as updateOraclePriceBeforeUserOperationPTB,
2766
- ge as updateOraclePricesPTB,
2767
- $t as updatePythPriceFeeds,
2768
- mr as verifyHealthFactorPTB,
2768
+ Yt as requireNaviGraphQLClient,
2769
+ M as resolveNaviOpenApiEndpoint,
2770
+ jr as summaryLendingRewards,
2771
+ gr as updateOraclePriceBeforeUserOperationPTB,
2772
+ he as updateOraclePricesPTB,
2773
+ Et as updatePythPriceFeeds,
2774
+ fr as verifyHealthFactorPTB,
2769
2775
  O as withCache,
2770
- A as withSingleton,
2771
- xt as withdrawCoinPTB
2776
+ S as withSingleton,
2777
+ er as withdrawCoinPTB
2772
2778
  };
2773
2779
  //# sourceMappingURL=index.esm.js.map