@naviprotocol/lending 1.4.5-beta.1 → 1.4.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,137 +1,137 @@
1
1
  import { Transaction as F } from "@mysten/sui/transactions";
2
- import { bcs as m, toHex as ce, fromHex as se } from "@mysten/bcs";
3
- import { SuiClient as le, getFullnodeUrl as ue } from "@mysten/sui/client";
4
- import pe from "lodash.camelcase";
5
- import { normalizeStructTag as de } from "@mysten/sui/utils";
6
- import { SuiPriceServiceConnection as Q, SuiPythClient as me } from "@pythnetwork/pyth-sui-js";
2
+ import { bcs as d, toHex as ue, fromHex as pe } from "@mysten/bcs";
3
+ import { SuiClient as de, getFullnodeUrl as me } from "@mysten/sui/client";
4
+ import fe from "lodash.camelcase";
5
+ import { normalizeStructTag as ye } from "@mysten/sui/utils";
6
+ import { SuiPriceServiceConnection as x, SuiPythClient as ge } from "@pythnetwork/pyth-sui-js";
7
7
  import p from "bignumber.js";
8
8
  import { bcs as C } from "@mysten/sui/bcs";
9
- const K = m.bytes(32).transform({
9
+ const J = d.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
- input: (e) => se(e),
12
- output: (e) => ce(e)
13
- }), Ge = m.struct("IncentiveAPYInfo", {
11
+ input: (e) => pe(e),
12
+ output: (e) => ue(e)
13
+ }), Je = d.struct("IncentiveAPYInfo", {
14
14
  /** Asset identifier */
15
- asset_id: m.u8(),
15
+ asset_id: d.u8(),
16
16
  /** Annual Percentage Yield as a 256-bit integer */
17
- apy: m.u256(),
17
+ apy: d.u256(),
18
18
  /** List of supported coin types for this incentive */
19
- coin_types: m.vector(m.string())
20
- }), fe = m.struct("IncentivePoolInfo", {
19
+ coin_types: d.vector(d.string())
20
+ }), he = d.struct("IncentivePoolInfo", {
21
21
  /** Unique pool identifier */
22
- pool_id: K,
22
+ pool_id: J,
23
23
  /** Address holding the incentive funds */
24
- funds: K,
24
+ funds: J,
25
25
  /** Current phase of the incentive program */
26
- phase: m.u64(),
26
+ phase: d.u64(),
27
27
  /** Timestamp when the incentive started */
28
- start_at: m.u64(),
28
+ start_at: d.u64(),
29
29
  /** Timestamp when the incentive ends */
30
- end_at: m.u64(),
30
+ end_at: d.u64(),
31
31
  /** Timestamp when the incentive was closed */
32
- closed_at: m.u64(),
32
+ closed_at: d.u64(),
33
33
  /** Total supply of incentive tokens */
34
- total_supply: m.u64(),
34
+ total_supply: d.u64(),
35
35
  /** Asset identifier for the incentive */
36
- asset_id: m.u8(),
36
+ asset_id: d.u8(),
37
37
  /** Option type for the incentive */
38
- option: m.u8(),
38
+ option: d.u8(),
39
39
  /** Factor used in incentive calculations */
40
- factor: m.u256(),
40
+ factor: d.u256(),
41
41
  /** Amount of incentives already distributed */
42
- distributed: m.u64(),
42
+ distributed: d.u64(),
43
43
  /** Amount of incentives currently available */
44
- available: m.u256(),
44
+ available: d.u256(),
45
45
  /** Total amount of incentives */
46
- total: m.u256()
47
- }), ze = m.struct("IncentivePoolInfoByPhase", {
46
+ total: d.u256()
47
+ }), Ze = d.struct("IncentivePoolInfoByPhase", {
48
48
  /** Phase number */
49
- phase: m.u64(),
49
+ phase: d.u64(),
50
50
  /** List of incentive pools in this phase */
51
- pools: m.vector(fe)
52
- }), Ke = m.struct("OracleInfo", {
51
+ pools: d.vector(he)
52
+ }), Qe = d.struct("OracleInfo", {
53
53
  /** Oracle identifier */
54
- oracle_id: m.u8(),
54
+ oracle_id: d.u8(),
55
55
  /** Current price as a 256-bit integer */
56
- price: m.u256(),
56
+ price: d.u256(),
57
57
  /** Number of decimal places for the price */
58
- decimals: m.u8(),
58
+ decimals: d.u8(),
59
59
  /** Whether the oracle data is valid */
60
- valid: m.bool()
61
- }), Ye = m.struct("FlashLoanAssetConfig", {
60
+ valid: d.bool()
61
+ }), Xe = d.struct("FlashLoanAssetConfig", {
62
62
  /** Unique identifier for the flash loan asset */
63
- id: m.string(),
63
+ id: d.string(),
64
64
  /** Asset identifier */
65
- asset_id: m.u8(),
65
+ asset_id: d.u8(),
66
66
  /** Coin type for the asset */
67
- coin_type: m.string(),
67
+ coin_type: d.string(),
68
68
  /** Pool identifier for the flash loan */
69
- pool_id: m.string(),
69
+ pool_id: d.string(),
70
70
  /** Rate paid to suppliers for flash loans */
71
- rate_to_supplier: m.u64(),
71
+ rate_to_supplier: d.u64(),
72
72
  /** Rate paid to treasury for flash loans */
73
- rate_to_treasury: m.u64(),
73
+ rate_to_treasury: d.u64(),
74
74
  /** Maximum flash loan amount */
75
- max: m.u64(),
75
+ max: d.u64(),
76
76
  /** Minimum flash loan amount */
77
- min: m.u64()
78
- }), Je = m.struct("ReserveDataInfo", {
77
+ min: d.u64()
78
+ }), ve = d.struct("ReserveDataInfo", {
79
79
  /** Reserve identifier */
80
- id: m.u8(),
80
+ id: d.u8(),
81
81
  /** Oracle identifier for price feeds */
82
- oracle_id: m.u8(),
82
+ oracle_id: d.u8(),
83
83
  /** Coin type for the reserve */
84
- coin_type: m.string(),
84
+ coin_type: d.string(),
85
85
  /** Maximum supply capacity */
86
- supply_cap: m.u256(),
86
+ supply_cap: d.u256(),
87
87
  /** Maximum borrow capacity */
88
- borrow_cap: m.u256(),
88
+ borrow_cap: d.u256(),
89
89
  /** Current supply interest rate */
90
- supply_rate: m.u256(),
90
+ supply_rate: d.u256(),
91
91
  /** Current borrow interest rate */
92
- borrow_rate: m.u256(),
92
+ borrow_rate: d.u256(),
93
93
  /** Current supply index for interest calculation */
94
- supply_index: m.u256(),
94
+ supply_index: d.u256(),
95
95
  /** Current borrow index for interest calculation */
96
- borrow_index: m.u256(),
96
+ borrow_index: d.u256(),
97
97
  /** Total amount supplied to the reserve */
98
- total_supply: m.u256(),
98
+ total_supply: d.u256(),
99
99
  /** Total amount borrowed from the reserve */
100
- total_borrow: m.u256(),
100
+ total_borrow: d.u256(),
101
101
  /** Timestamp of last update */
102
- last_update_at: m.u64(),
102
+ last_update_at: d.u64(),
103
103
  /** Loan-to-Value ratio for collateral */
104
- ltv: m.u256(),
104
+ ltv: d.u256(),
105
105
  /** Treasury factor for fee calculations */
106
- treasury_factor: m.u256(),
106
+ treasury_factor: d.u256(),
107
107
  /** Current treasury balance */
108
- treasury_balance: m.u256(),
108
+ treasury_balance: d.u256(),
109
109
  /** Base interest rate */
110
- base_rate: m.u256(),
110
+ base_rate: d.u256(),
111
111
  /** Interest rate multiplier */
112
- multiplier: m.u256(),
112
+ multiplier: d.u256(),
113
113
  /** Jump rate multiplier for high utilization */
114
- jump_rate_multiplier: m.u256(),
114
+ jump_rate_multiplier: d.u256(),
115
115
  /** Reserve factor for protocol fees */
116
- reserve_factor: m.u256(),
116
+ reserve_factor: d.u256(),
117
117
  /** Optimal utilization rate */
118
- optimal_utilization: m.u256(),
118
+ optimal_utilization: d.u256(),
119
119
  /** Liquidation ratio threshold */
120
- liquidation_ratio: m.u256(),
120
+ liquidation_ratio: d.u256(),
121
121
  /** Liquidation bonus for liquidators */
122
- liquidation_bonus: m.u256(),
122
+ liquidation_bonus: d.u256(),
123
123
  /** Liquidation threshold */
124
- liquidation_threshold: m.u256()
125
- }), ye = m.struct("UserStateInfo", {
124
+ liquidation_threshold: d.u256()
125
+ }), we = d.struct("UserStateInfo", {
126
126
  /** Asset identifier */
127
- asset_id: m.u8(),
127
+ asset_id: d.u8(),
128
128
  /** User's current borrow balance */
129
- borrow_balance: m.u256(),
129
+ borrow_balance: d.u256(),
130
130
  /** User's current supply balance */
131
- supply_balance: m.u256()
132
- }), ge = "1.4.5-beta.1", V = {
133
- version: ge
134
- }, he = V.version, ve = () => {
131
+ supply_balance: d.u256()
132
+ }), be = "1.4.5-beta.3", E = {
133
+ version: be
134
+ }, ke = E.version, _e = () => {
135
135
  if (typeof process < "u" && process.versions && process.versions.node)
136
136
  try {
137
137
  const e = require("os"), r = process.version, o = e.type(), n = e.arch();
@@ -140,13 +140,13 @@ const K = m.bytes(32).transform({
140
140
  return `Node.js ${process.version}; OS/Unknown (Error)`;
141
141
  }
142
142
  return "Node/Unknown";
143
- }, we = () => {
143
+ }, Ce = () => {
144
144
  let e = "";
145
- return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${he} (${ve()})`), e;
146
- }, Y = we(), S = new le({
147
- url: ue("mainnet")
145
+ return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ke} (${_e()})`), e;
146
+ }, Z = Ce(), V = new de({
147
+ url: me("mainnet")
148
148
  });
149
- function X(e) {
149
+ function ee(e) {
150
150
  const r = [];
151
151
  return e.forEach((o, n) => {
152
152
  const t = n === e.length - 1;
@@ -157,41 +157,41 @@ function X(e) {
157
157
  r.push(o);
158
158
  }), JSON.stringify(r);
159
159
  }
160
- function B(e) {
160
+ function P(e) {
161
161
  const r = {};
162
162
  return (...o) => {
163
- const n = X(o);
163
+ const n = ee(o);
164
164
  return r[n] || (r[n] = e(...o).finally(() => {
165
165
  delete r[n];
166
166
  })), r[n];
167
167
  };
168
168
  }
169
- function P(e) {
169
+ function M(e) {
170
170
  let r = {};
171
171
  return (...o) => {
172
- const n = o[o.length - 1], t = X(o), a = r[t];
172
+ const n = o[o.length - 1], t = ee(o), a = r[t];
173
173
  return !n?.disableCache && typeof a?.data < "u" && (typeof n?.cacheTime > "u" || n.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...o).then((s) => (r[t] = {
174
174
  data: s,
175
175
  cacheAt: Date.now()
176
176
  }, s));
177
177
  };
178
178
  }
179
- function H(e) {
180
- return Array.isArray(e) ? e.map((r) => H(r)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
179
+ function K(e) {
180
+ return Array.isArray(e) ? e.map((r) => K(r)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
181
181
  (r, o) => ({
182
182
  ...r,
183
- [pe(o)]: H(e[o])
183
+ [fe(o)]: K(e[o])
184
184
  }),
185
185
  {}
186
186
  ) : e;
187
187
  }
188
- function h(e, r) {
188
+ function g(e, r) {
189
189
  return typeof e == "object" ? e : r(e);
190
190
  }
191
- function be(e, r) {
191
+ function je(e, r) {
192
192
  return typeof r == "string" ? e.object(r) : typeof r == "object" && r.$kind ? r : e.object(r.contract.pool);
193
193
  }
194
- function W(e, r, o) {
194
+ function H(e, r, o) {
195
195
  if (e.results && e.results.length > 0) {
196
196
  if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
197
197
  return e.results[0].returnValues.map((n, t) => (r[t] || r[0]).parse(Uint8Array.from(n[0])));
@@ -199,36 +199,36 @@ function W(e, r, o) {
199
199
  return console.log(`Get an error, msg: ${e.error}`), [];
200
200
  return [];
201
201
  }
202
- function b(e) {
203
- return de(e);
202
+ function k(e) {
203
+ return ye(e);
204
204
  }
205
- function x(e) {
205
+ function te(e) {
206
206
  const r = (e || 0) / Math.pow(10, 27);
207
207
  return r > Math.pow(10, 5) ? 1 / 0 : r;
208
208
  }
209
- new Q("https://hermes.pyth.network", {
209
+ new x("https://hermes.pyth.network", {
210
210
  timeout: 2e4
211
211
  });
212
- const ke = 27, J = (e, r) => {
212
+ const Ie = 27, Q = (e, r) => {
213
213
  if (!Number(e) || !Number(r)) return new p(0);
214
- const o = new p(1).shiftedBy(1 * ke), n = o.multipliedBy(new p(0.5));
214
+ const o = new p(1).shiftedBy(1 * Ie), n = o.multipliedBy(new p(0.5));
215
215
  return new p(e).multipliedBy(new p(r)).plus(n).dividedBy(o).integerValue(p.ROUND_DOWN);
216
- }, M = Y ? {
217
- "User-Agent": Y
216
+ }, D = Z ? {
217
+ "User-Agent": Z
218
218
  } : {};
219
- function G(e, r = "uniqueId") {
219
+ function z(e, r = "uniqueId") {
220
220
  return e.reduce(
221
221
  (o, n) => (o[n[r]] = n, o),
222
222
  {}
223
223
  );
224
224
  }
225
- function Z(e, r = "uniqueId") {
225
+ function X(e, r = "uniqueId") {
226
226
  return e.reduce(
227
227
  (o, n) => (o[n[r]] = n, o),
228
228
  {}
229
229
  );
230
230
  }
231
- function L(e, r) {
231
+ function W(e, r) {
232
232
  const o = e.emodes.find((t) => t.emodeId === r.emodeId);
233
233
  if (!o)
234
234
  throw new Error("EMode not found in pool");
@@ -242,88 +242,88 @@ function L(e, r) {
242
242
  isEMode: !0
243
243
  };
244
244
  }
245
- function _e(e) {
245
+ function Te(e) {
246
246
  const [r, o] = e.split("-");
247
247
  return !r || !o ? null : {
248
248
  marketKey: r,
249
249
  poolId: parseInt(o)
250
250
  };
251
251
  }
252
- function T() {
252
+ function $() {
253
253
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
254
254
  }
255
255
  var R = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(R || {});
256
- const q = P(
257
- B(
256
+ const q = M(
257
+ P(
258
258
  async (e) => {
259
- const r = (e?.markets || [E.main]).map((t) => j(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${V.version}&market=${r.map(
259
+ const r = (e?.markets || [U.main]).map((t) => T(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.map(
260
260
  (t) => t.key
261
- )}`, n = await fetch(o, { headers: M }).then((t) => t.json());
261
+ )}`, n = await fetch(o, { headers: D }).then((t) => t.json());
262
262
  return n.data.forEach((t) => {
263
263
  const s = n.meta.emodes.filter((f) => {
264
- const k = j(f.marketId);
265
- return t.market === k.key && f.isActive;
266
- }).filter((f) => !!f.assets.find((k) => k.assetId === t.id));
264
+ const w = T(f.marketId);
265
+ return t.market === w.key && f.isActive;
266
+ }).filter((f) => !!f.assets.find((w) => w.assetId === t.id));
267
267
  t.emodes = s;
268
- const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), c = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), l = p(i).multipliedBy(t.oracle.price).toString(), d = p(c).multipliedBy(t.oracle.price).toString(), y = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
268
+ const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), c = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), u = p(i).multipliedBy(t.oracle.price).toString(), m = p(c).multipliedBy(t.oracle.price).toString(), h = p(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), v = p.max(
269
269
  p(t.borrowedAmount),
270
270
  p(t.validBorrowAmount)
271
- ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), g = p(y).multipliedBy(t.oracle.price).toString(), u = p(v).multipliedBy(t.oracle.price).toString();
272
- t.poolSupplyAmount = i, t.poolBorrowAmount = c, t.poolSupplyValue = l, t.poolBorrowValue = d, t.poolSupplyCapAmount = y, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = g, t.poolBorrowCapValue = u;
271
+ ).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), y = p(h).multipliedBy(t.oracle.price).toString(), l = p(v).multipliedBy(t.oracle.price).toString();
272
+ t.poolSupplyAmount = i, t.poolBorrowAmount = c, t.poolSupplyValue = u, t.poolBorrowValue = m, t.poolSupplyCapAmount = h, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = y, t.poolBorrowCapValue = l;
273
273
  }), n.data;
274
274
  }
275
275
  )
276
276
  );
277
- async function A(e, r) {
277
+ async function S(e, r) {
278
278
  let o = r?.market;
279
279
  if (typeof e == "string") {
280
- const a = _e(e);
280
+ const a = Te(e);
281
281
  a && (o = a.marketKey, e = a.poolId);
282
282
  }
283
283
  const n = await q({
284
284
  ...r,
285
- markets: [o || U],
286
- cacheTime: w
285
+ markets: [o || O],
286
+ cacheTime: b
287
287
  });
288
288
  if (typeof e == "object")
289
289
  return e;
290
- const t = n.find((a) => typeof e == "string" ? b(a.suiCoinType) === b(e) : typeof e == "number" ? a.id === e : !1);
290
+ const t = n.find((a) => typeof e == "string" ? k(a.suiCoinType) === k(e) : typeof e == "number" ? a.id === e : !1);
291
291
  if (!t)
292
292
  throw new Error("Pool not found");
293
293
  return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
294
294
  }
295
- const Ze = P(
296
- B(async (e) => {
297
- const r = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${V.version}`;
298
- return (await fetch(r, { headers: M }).then((n) => n.json())).data;
295
+ const xe = M(
296
+ P(async (e) => {
297
+ const r = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${E.version}`;
298
+ return (await fetch(r, { headers: D }).then((n) => n.json())).data;
299
299
  })
300
- ), Qe = P(
301
- B(
300
+ ), et = M(
301
+ P(
302
302
  async (e) => {
303
- const r = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${V.version}`;
304
- return await fetch(r, { headers: M }).then((n) => n.json());
303
+ const r = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${E.version}`;
304
+ return await fetch(r, { headers: D }).then((n) => n.json());
305
305
  }
306
306
  )
307
307
  );
308
- async function Ce(e, r, o, n) {
308
+ async function Be(e, r, o, n) {
309
309
  const t = await _({
310
310
  ...n,
311
- cacheTime: w
312
- }), a = await A(r, n);
311
+ cacheTime: b
312
+ }), a = await S(r, n);
313
313
  n?.market;
314
314
  const s = n?.env || "prod";
315
315
  if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
316
316
  throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
317
317
  const i = typeof o == "object" && o.$kind === "GasCoin";
318
- if (b(a.suiCoinType) === b("0x2::sui::SUI") && i) {
318
+ if (k(a.suiCoinType) === k("0x2::sui::SUI") && i) {
319
319
  if (!n?.amount)
320
320
  throw new Error("Amount is required for sui coin");
321
321
  o = e.splitCoins(o, [n.amount]);
322
322
  }
323
323
  let c;
324
- return typeof n?.amount < "u" ? c = h(n.amount, e.pure.u64) : c = e.moveCall({
324
+ return typeof n?.amount < "u" ? c = g(n.amount, e.pure.u64) : c = e.moveCall({
325
325
  target: "0x2::coin::value",
326
- arguments: [h(o, e.object)],
326
+ arguments: [g(o, e.object)],
327
327
  typeArguments: [a.suiCoinType]
328
328
  }), n?.accountCap ? e.moveCall({
329
329
  target: `${t.package}::incentive_v3::deposit_with_account_cap`,
@@ -332,10 +332,10 @@ async function Ce(e, r, o, n) {
332
332
  e.object(t.storage),
333
333
  e.object(a.contract.pool),
334
334
  e.pure.u8(a.id),
335
- h(o, e.object),
335
+ g(o, e.object),
336
336
  e.object(t.incentiveV2),
337
337
  e.object(t.incentiveV3),
338
- h(n.accountCap, e.object)
338
+ g(n.accountCap, e.object)
339
339
  ],
340
340
  typeArguments: [a.suiCoinType]
341
341
  }) : e.moveCall({
@@ -345,7 +345,7 @@ async function Ce(e, r, o, n) {
345
345
  e.object(t.storage),
346
346
  e.object(a.contract.pool),
347
347
  e.pure.u8(a.id),
348
- h(o, e.object),
348
+ g(o, e.object),
349
349
  c,
350
350
  e.object(t.incentiveV2),
351
351
  e.object(t.incentiveV3)
@@ -356,15 +356,15 @@ async function Ce(e, r, o, n) {
356
356
  arguments: [e.object(a.contract.pool), e.object("0x05")]
357
357
  }), e;
358
358
  }
359
- async function Xe(e, r, o, n) {
359
+ async function tt(e, r, o, n) {
360
360
  const t = await _({
361
361
  ...n,
362
- cacheTime: w
363
- }), a = await A(r, n), s = h(o, e.pure.u64);
362
+ cacheTime: b
363
+ }), a = await S(r, n), s = g(o, e.pure.u64);
364
364
  let i;
365
365
  if (t.version === 1)
366
366
  if (n?.accountCap) {
367
- const [l] = e.moveCall({
367
+ const [u] = e.moveCall({
368
368
  target: `${t.package}::incentive_v3::withdraw_with_account_cap`,
369
369
  arguments: [
370
370
  e.object("0x06"),
@@ -375,13 +375,13 @@ async function Xe(e, r, o, n) {
375
375
  s,
376
376
  e.object(t.incentiveV2),
377
377
  e.object(t.incentiveV3),
378
- h(n.accountCap, e.object)
378
+ g(n.accountCap, e.object)
379
379
  ],
380
380
  typeArguments: [a.suiCoinType]
381
381
  });
382
- i = l;
382
+ i = u;
383
383
  } else {
384
- const [l] = e.moveCall({
384
+ const [u] = e.moveCall({
385
385
  target: `${t.package}::incentive_v3::withdraw`,
386
386
  arguments: [
387
387
  e.object("0x06"),
@@ -395,10 +395,10 @@ async function Xe(e, r, o, n) {
395
395
  ],
396
396
  typeArguments: [a.suiCoinType]
397
397
  });
398
- i = l;
398
+ i = u;
399
399
  }
400
400
  else if (n?.accountCap) {
401
- const [l] = e.moveCall({
401
+ const [u] = e.moveCall({
402
402
  target: `${t.package}::incentive_v3::withdraw_with_account_cap_v2`,
403
403
  arguments: [
404
404
  e.object("0x06"),
@@ -409,14 +409,14 @@ async function Xe(e, r, o, n) {
409
409
  s,
410
410
  e.object(t.incentiveV2),
411
411
  e.object(t.incentiveV3),
412
- h(n.accountCap, e.object),
412
+ g(n.accountCap, e.object),
413
413
  e.object("0x05")
414
414
  ],
415
415
  typeArguments: [a.suiCoinType]
416
416
  });
417
- i = l;
417
+ i = u;
418
418
  } else {
419
- const [l] = e.moveCall({
419
+ const [u] = e.moveCall({
420
420
  target: `${t.package}::incentive_v3::withdraw_v2`,
421
421
  arguments: [
422
422
  e.object("0x06"),
@@ -431,7 +431,7 @@ async function Xe(e, r, o, n) {
431
431
  ],
432
432
  typeArguments: [a.suiCoinType]
433
433
  });
434
- i = l;
434
+ i = u;
435
435
  }
436
436
  return e.moveCall({
437
437
  target: "0x2::coin::from_balance",
@@ -439,18 +439,18 @@ async function Xe(e, r, o, n) {
439
439
  typeArguments: [a.suiCoinType]
440
440
  });
441
441
  }
442
- async function xe(e, r, o, n) {
442
+ async function ot(e, r, o, n) {
443
443
  const t = await _({
444
444
  ...n,
445
- cacheTime: w
446
- }), a = await A(r, n);
445
+ cacheTime: b
446
+ }), a = await S(r, n);
447
447
  if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
448
448
  throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
449
- const s = h(o, e.pure.u64);
449
+ const s = g(o, e.pure.u64);
450
450
  let i;
451
451
  if (t.version === 1)
452
452
  if (n?.accountCap) {
453
- const [l] = e.moveCall({
453
+ const [u] = e.moveCall({
454
454
  target: `${t.package}::incentive_v3::borrow_with_account_cap`,
455
455
  arguments: [
456
456
  e.object("0x06"),
@@ -461,13 +461,13 @@ async function xe(e, r, o, n) {
461
461
  s,
462
462
  e.object(t.incentiveV2),
463
463
  e.object(t.incentiveV3),
464
- h(n.accountCap, e.object)
464
+ g(n.accountCap, e.object)
465
465
  ],
466
466
  typeArguments: [a.suiCoinType]
467
467
  });
468
- i = l;
468
+ i = u;
469
469
  } else {
470
- const [l] = e.moveCall({
470
+ const [u] = e.moveCall({
471
471
  target: `${t.package}::incentive_v3::borrow`,
472
472
  arguments: [
473
473
  e.object("0x06"),
@@ -481,10 +481,10 @@ async function xe(e, r, o, n) {
481
481
  ],
482
482
  typeArguments: [a.suiCoinType]
483
483
  });
484
- i = l;
484
+ i = u;
485
485
  }
486
486
  else if (n?.accountCap) {
487
- const [l] = e.moveCall({
487
+ const [u] = e.moveCall({
488
488
  target: `${t.package}::incentive_v3::borrow_with_account_cap_v2`,
489
489
  arguments: [
490
490
  e.object("0x06"),
@@ -495,14 +495,14 @@ async function xe(e, r, o, n) {
495
495
  s,
496
496
  e.object(t.incentiveV2),
497
497
  e.object(t.incentiveV3),
498
- h(n.accountCap, e.object),
498
+ g(n.accountCap, e.object),
499
499
  e.object("0x05")
500
500
  ],
501
501
  typeArguments: [a.suiCoinType]
502
502
  });
503
- i = l;
503
+ i = u;
504
504
  } else {
505
- const [l] = e.moveCall({
505
+ const [u] = e.moveCall({
506
506
  target: `${t.package}::incentive_v3::borrow_v2`,
507
507
  arguments: [
508
508
  e.object("0x06"),
@@ -517,7 +517,7 @@ async function xe(e, r, o, n) {
517
517
  ],
518
518
  typeArguments: [a.suiCoinType]
519
519
  });
520
- i = l;
520
+ i = u;
521
521
  }
522
522
  return e.moveCall({
523
523
  target: "0x2::coin::from_balance",
@@ -525,20 +525,20 @@ async function xe(e, r, o, n) {
525
525
  typeArguments: [a.suiCoinType]
526
526
  });
527
527
  }
528
- async function et(e, r, o, n) {
528
+ async function rt(e, r, o, n) {
529
529
  const t = await _({
530
530
  ...n,
531
- cacheTime: w
532
- }), a = await A(r, n), s = typeof o == "object" && o.$kind === "GasCoin";
533
- if (b(a.suiCoinType) === b("0x2::sui::SUI") && s) {
531
+ cacheTime: b
532
+ }), a = await S(r, n), s = typeof o == "object" && o.$kind === "GasCoin";
533
+ if (k(a.suiCoinType) === k("0x2::sui::SUI") && s) {
534
534
  if (!n?.amount)
535
535
  throw new Error("Amount is required for sui coin");
536
536
  o = e.splitCoins(o, [n.amount]);
537
537
  }
538
538
  let i;
539
- if (typeof n?.amount < "u" ? i = h(n.amount, e.pure.u64) : i = e.moveCall({
539
+ if (typeof n?.amount < "u" ? i = g(n.amount, e.pure.u64) : i = e.moveCall({
540
540
  target: "0x2::coin::value",
541
- arguments: [h(o, e.object)],
541
+ arguments: [g(o, e.object)],
542
542
  typeArguments: [a.suiCoinType]
543
543
  }), n?.accountCap) {
544
544
  const [c] = e.moveCall({
@@ -549,10 +549,10 @@ async function et(e, r, o, n) {
549
549
  e.object(t.storage),
550
550
  e.object(a.contract.pool),
551
551
  e.pure.u8(a.id),
552
- h(o, e.object),
552
+ g(o, e.object),
553
553
  e.object(t.incentiveV2),
554
554
  e.object(t.incentiveV3),
555
- h(n.accountCap, e.object)
555
+ g(n.accountCap, e.object)
556
556
  ],
557
557
  typeArguments: [a.suiCoinType]
558
558
  });
@@ -570,7 +570,7 @@ async function et(e, r, o, n) {
570
570
  e.object(t.storage),
571
571
  e.object(a.contract.pool),
572
572
  e.pure.u8(a.id),
573
- h(o, e.object),
573
+ g(o, e.object),
574
574
  i,
575
575
  e.object(t.incentiveV2),
576
576
  e.object(t.incentiveV3)
@@ -578,15 +578,15 @@ async function et(e, r, o, n) {
578
578
  typeArguments: [a.suiCoinType]
579
579
  }), e;
580
580
  }
581
- const tt = P(
582
- B(
581
+ const nt = M(
582
+ P(
583
583
  async (e) => {
584
584
  const r = await _({
585
585
  ...e
586
586
  });
587
587
  if (e?.address && typeof e?.asset < "u")
588
588
  try {
589
- const t = await A(e.asset, e), a = e?.client ?? S, s = new F();
589
+ const t = await S(e.asset, e), a = e?.client ?? V, s = new F();
590
590
  s.moveCall({
591
591
  target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
592
592
  arguments: [
@@ -600,19 +600,19 @@ const tt = P(
600
600
  const i = await a.devInspectTransactionBlock({
601
601
  transactionBlock: s,
602
602
  sender: e.address
603
- }), c = W(i, [C.u64()]);
603
+ }), c = H(i, [C.u64()]);
604
604
  return (Number(c[0]) || 0) / 100;
605
605
  } catch (t) {
606
606
  console.error(t);
607
607
  }
608
- const n = (await S.getObject({
608
+ const n = (await V.getObject({
609
609
  id: r.incentiveV3,
610
610
  options: { showType: !0, showOwner: !0, showContent: !0 }
611
611
  })).data.content.fields.borrow_fee_rate;
612
612
  return Number(n) / 100;
613
613
  }
614
614
  )
615
- ), U = "main", E = {
615
+ ), O = "main", U = {
616
616
  main: {
617
617
  id: 0,
618
618
  key: "main",
@@ -634,34 +634,34 @@ const tt = P(
634
634
  name: "Sui Eco Market"
635
635
  }
636
636
  };
637
- class je {
637
+ class Ae {
638
638
  constructor(r, o) {
639
639
  this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
640
640
  marketTotalSupplyValue: "0",
641
641
  marketTotalBorrowValue: "0"
642
- }, this.config = j(r), this.initPools(o);
642
+ }, this.config = T(r), this.initPools(o);
643
643
  }
644
644
  get overview() {
645
645
  return this._overview;
646
646
  }
647
647
  initPools(r) {
648
- const o = G(this.pools), n = Z(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
648
+ const o = z(this.pools), n = X(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
649
649
  let s = p(0), i = p(0);
650
650
  r.forEach((c) => {
651
651
  if (!this.checkMarket(c.market)) {
652
652
  console.warn(`Pool is not in market ${this.config.name}`, c);
653
653
  return;
654
654
  }
655
- o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((d) => {
656
- n[d.uniqueId] || this.emodes.push(d), d.assets.forEach((y) => {
657
- y.isDebt && d.assets.find(
658
- (g) => g.isCollateral && g.ltv > 0 && g.assetId !== c.id
659
- ) && t.add(c.uniqueId), y.isCollateral && d.assets.find((g) => g.isDebt && g.assetId !== c.id) && a.add(c.uniqueId);
655
+ o[c.uniqueId] || this.pools.push(c), c?.emodes?.forEach((m) => {
656
+ n[m.uniqueId] || this.emodes.push(m), m.assets.forEach((h) => {
657
+ h.isDebt && m.assets.find(
658
+ (y) => y.isCollateral && y.ltv > 0 && y.assetId !== c.id
659
+ ) && t.add(c.uniqueId), h.isCollateral && m.assets.find((y) => y.isDebt && y.assetId !== c.id) && a.add(c.uniqueId);
660
660
  });
661
661
  }), i = i.plus(c.poolBorrowValue), s = s.plus(c.poolSupplyValue);
662
- }), this.poolMap = G(this.pools, "id"), this.emodeMap = Z(this.emodes, "emodeId"), this.emodes.forEach((c) => {
663
- const l = this.getEModePools(c.emodeId);
664
- this.emodePools.push(...l);
662
+ }), this.poolMap = z(this.pools, "id"), this.emodeMap = X(this.emodes, "emodeId"), this.emodes.forEach((c) => {
663
+ const u = this.getEModePools(c.emodeId);
664
+ this.emodePools.push(...u);
665
665
  }), this._overview = {
666
666
  marketTotalSupplyValue: s.toString(),
667
667
  marketTotalBorrowValue: i.toString()
@@ -697,13 +697,13 @@ class je {
697
697
  return typeof r == "number" && r === this.config.id && (o = !0), typeof r == "string" && r === this.config.key && (o = !0), typeof r == "object" && r.id === this.config.id && (o = !0), o;
698
698
  }
699
699
  }
700
- const j = (e) => {
701
- const o = Object.values(E).find((n) => typeof e == "number" ? n.id === e : typeof e == "string" ? n.key === e : n.id === e.id);
700
+ const T = (e) => {
701
+ const o = Object.values(U).find((n) => typeof e == "number" ? n.id === e : typeof e == "string" ? n.key === e : n.id === e.id);
702
702
  if (!o)
703
703
  throw new Error("Market not found");
704
704
  return o;
705
- }, Ie = P(
706
- B(
705
+ }, $e = M(
706
+ P(
707
707
  async (e, r) => {
708
708
  const o = await q({
709
709
  cacheTime: 6e4,
@@ -711,26 +711,26 @@ const j = (e) => {
711
711
  markets: e
712
712
  });
713
713
  return e.map((n) => {
714
- const t = j(n), a = o.filter((s) => s.market === t.key);
715
- return new je(n, a);
714
+ const t = T(n), a = o.filter((s) => s.market === t.key);
715
+ return new Ae(n, a);
716
716
  });
717
717
  }
718
718
  )
719
- ), ot = P(
720
- B(
721
- async (e, r) => (await Ie([e], r))[0]
719
+ ), at = M(
720
+ P(
721
+ async (e, r) => (await $e([e], r))[0]
722
722
  )
723
- ), _ = P(
724
- B(
723
+ ), _ = M(
724
+ P(
725
725
  async (e) => {
726
- const r = j(e?.market || U), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${V.version}&market=${r.key}`;
727
- return (await fetch(o, { headers: M }).then((t) => t.json())).data;
726
+ const r = T(e?.market || O), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${E.version}&market=${r.key}`;
727
+ return (await fetch(o, { headers: D }).then((t) => t.json())).data;
728
728
  }
729
729
  )
730
- ), w = 1e3 * 60 * 5;
731
- async function Te(e, r) {
730
+ ), b = 1e3 * 60 * 5;
731
+ async function Pe(e, r) {
732
732
  const o = await _({
733
- cacheTime: w,
733
+ cacheTime: b,
734
734
  ...r
735
735
  });
736
736
  return e.moveCall({
@@ -738,9 +738,9 @@ async function Te(e, r) {
738
738
  arguments: []
739
739
  });
740
740
  }
741
- async function Be(e, r, o) {
741
+ async function Se(e, r, o) {
742
742
  const n = await _({
743
- cacheTime: w,
743
+ cacheTime: b,
744
744
  ...o
745
745
  });
746
746
  return e.moveCall({
@@ -748,63 +748,63 @@ async function Be(e, r, o) {
748
748
  arguments: [r]
749
749
  });
750
750
  }
751
- async function Ae(e, r, o) {
751
+ async function Me(e, r, o) {
752
752
  const n = await _({
753
753
  ...o,
754
- cacheTime: w
754
+ cacheTime: b
755
755
  });
756
756
  return o?.accountCap ? e.moveCall({
757
757
  target: `${n.package}::lending::enter_emode_with_account_cap`,
758
758
  arguments: [
759
759
  e.object(n.storage),
760
- h(r, e.pure.u64),
761
- h(o.accountCap, e.object)
760
+ g(r, e.pure.u64),
761
+ g(o.accountCap, e.object)
762
762
  ]
763
763
  }) : e.moveCall({
764
764
  target: `${n.package}::lending::enter_emode`,
765
- arguments: [e.object(n.storage), h(r, e.pure.u64)]
765
+ arguments: [e.object(n.storage), g(r, e.pure.u64)]
766
766
  }), e;
767
767
  }
768
- async function rt(e, r) {
768
+ async function it(e, r) {
769
769
  const o = await _({
770
770
  ...r,
771
- cacheTime: w
771
+ cacheTime: b
772
772
  });
773
773
  return r?.accountCap ? e.moveCall({
774
774
  target: `${o.package}::lending::exit_emode_with_account_cap`,
775
- arguments: [e.object(o.storage), h(r.accountCap, e.object)]
775
+ arguments: [e.object(o.storage), g(r.accountCap, e.object)]
776
776
  }) : e.moveCall({
777
777
  target: `${o.package}::lending::exit_emode`,
778
778
  arguments: [e.object(o.storage)]
779
779
  }), e;
780
780
  }
781
- async function nt(e, r, o) {
781
+ async function ct(e, r, o) {
782
782
  const n = await _({
783
- cacheTime: w,
783
+ cacheTime: b,
784
784
  ...o
785
- }), t = await Te(e, o);
786
- await Ae(e, r, {
785
+ }), t = await Pe(e, o);
786
+ await Me(e, r, {
787
787
  ...o,
788
788
  accountCap: t
789
789
  });
790
- const a = await j(o?.market || U), s = await Be(e, t, o);
790
+ const a = await T(o?.market || O), s = await Se(e, t, o);
791
791
  return e.moveCall({
792
792
  target: `${n.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
793
793
  arguments: [
794
794
  e.object(n.emode.contract.registryObject),
795
795
  s,
796
- h(a.id, e.pure.u64),
797
- h(r, e.pure.u64)
796
+ g(a.id, e.pure.u64),
797
+ g(r, e.pure.u64)
798
798
  ]
799
799
  }), t;
800
800
  }
801
- const ee = P(
802
- B(
801
+ const oe = M(
802
+ P(
803
803
  async (e, r) => {
804
804
  const o = await _({
805
- cacheTime: w,
805
+ cacheTime: b,
806
806
  ...r
807
- }), n = new F(), t = r?.client ?? S;
807
+ }), n = new F(), t = r?.client ?? V;
808
808
  n.moveCall({
809
809
  target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
810
810
  arguments: [n.object(o.emode.contract.registryObject), n.pure.address(e)]
@@ -812,24 +812,24 @@ const ee = P(
812
812
  const s = (await t.devInspectTransactionBlock({
813
813
  transactionBlock: n,
814
814
  sender: e
815
- })).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(s[0][0])), c = C.vector(C.u64()).parse(Uint8Array.from(s[1][0])), l = C.vector(C.Address).parse(Uint8Array.from(s[2][0]));
816
- return i.map((d, y) => ({
817
- marketId: Number(d),
818
- emodeId: Number(c[y]),
819
- accountCap: l[y].toString()
815
+ })).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(s[0][0])), c = C.vector(C.u64()).parse(Uint8Array.from(s[1][0])), u = C.vector(C.Address).parse(Uint8Array.from(s[2][0]));
816
+ return i.map((m, h) => ({
817
+ marketId: Number(m),
818
+ emodeId: Number(c[h]),
819
+ accountCap: u[h].toString()
820
820
  }));
821
821
  }
822
822
  )
823
823
  );
824
- function at(e) {
825
- return `${j(e.marketId).key}-${e.emodeId}`;
824
+ function st(e) {
825
+ return `${T(e.marketId).key}-${e.emodeId}`;
826
826
  }
827
- function it(e, r, o) {
827
+ function lt(e, r, o) {
828
828
  const n = typeof o?.balance == "number", t = n ? o.balance : 0;
829
829
  let a = 0;
830
830
  const s = [];
831
831
  let i = "";
832
- if (r.sort((c, l) => Number(l.balance) - Number(c.balance)).forEach((c) => {
832
+ if (r.sort((c, u) => Number(u.balance) - Number(c.balance)).forEach((c) => {
833
833
  if (!(n && a >= t) && Number(c.balance) !== 0) {
834
834
  if (i || (i = c.coinType), i !== c.coinType)
835
835
  throw new Error("All coins must be of the same type");
@@ -841,131 +841,153 @@ function it(e, r, o) {
841
841
  throw new Error(
842
842
  `Balance is less than the specified balance: ${a} < ${t}`
843
843
  );
844
- return b(i) === b("0x2::sui::SUI") && o?.useGasCoin ? n ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (s.length === 1 ? e.object(s[0]) : e.mergeCoins(s[0], s.slice(1)), n ? e.splitCoins(s[0], [e.pure.u64(t)]) : s[0]);
844
+ return k(i) === k("0x2::sui::SUI") && o?.useGasCoin ? n ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (s.length === 1 ? e.object(s[0]) : e.mergeCoins(s[0], s.slice(1)), n ? e.splitCoins(s[0], [e.pure.u64(t)]) : s[0]);
845
845
  }
846
- async function te(e, r, o, n, t, a, s) {
846
+ async function re(e, r, o, n, t, a, s) {
847
847
  const i = await _({
848
848
  ...s,
849
- cacheTime: w
850
- }), c = await A(o, s);
849
+ cacheTime: b
850
+ }), c = await S(o, s);
851
851
  return e.moveCall({
852
852
  target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
853
853
  arguments: [
854
854
  e.object("0x06"),
855
855
  e.object(i.storage),
856
856
  e.object(i.oracle.priceOracle),
857
- be(e, c),
858
- h(r, e.pure.address),
859
- h(c.id, e.pure.u8),
860
- h(n, e.pure.u64),
861
- h(t, e.pure.u64),
862
- h(a, e.pure.bool)
857
+ je(e, c),
858
+ g(r, e.pure.address),
859
+ g(c.id, e.pure.u8),
860
+ g(n, e.pure.u64),
861
+ g(t, e.pure.u64),
862
+ g(a, e.pure.bool)
863
863
  ],
864
864
  typeArguments: [c.suiCoinType]
865
865
  });
866
866
  }
867
- async function Pe(e, r, o) {
868
- return te(e, r, 0, 0, 0, !1, o);
867
+ async function Ve(e, r, o) {
868
+ return re(e, r, 0, 0, 0, !1, o);
869
869
  }
870
- async function oe(e, r, o) {
871
- const n = new F(), t = o?.client ?? S, a = await q({
870
+ async function ne(e, r, o) {
871
+ const n = new F(), t = o?.client ?? V, a = await q({
872
872
  ...o,
873
- markets: Object.values(E)
874
- }), s = G(a);
875
- for (let d of r) {
876
- const y = await _({
873
+ markets: Object.values(U)
874
+ }), s = z(a), c = Array.from(new Set(r.map((l) => l.market))).map((l) => T(l));
875
+ for (const l of c) {
876
+ const f = await _({
877
877
  ...o,
878
- cacheTime: w,
879
- market: d.market
878
+ cacheTime: b,
879
+ market: l.key
880
880
  });
881
881
  n.moveCall({
882
- target: `${y.uiGetter}::getter_unchecked::get_user_state`,
883
- arguments: [n.object(y.storage), n.pure.address(d.address)]
882
+ target: `${f.uiGetter}::getter::get_reserve_data`,
883
+ arguments: [n.object(f.storage)]
884
884
  });
885
885
  }
886
- const c = ((await t.devInspectTransactionBlock({
886
+ for (let l of r) {
887
+ const f = await _({
888
+ ...o,
889
+ cacheTime: b,
890
+ market: l.market
891
+ });
892
+ n.moveCall({
893
+ target: `${f.uiGetter}::getter_unchecked::get_user_state`,
894
+ arguments: [n.object(f.storage), n.pure.address(l.address)]
895
+ });
896
+ }
897
+ const m = (await t.devInspectTransactionBlock({
887
898
  transactionBlock: n,
888
899
  sender: e
889
- })).results || []).map((d) => d.returnValues?.map((y) => C.vector(ye).parse(Uint8Array.from(y[0])))[0] || []), l = [];
890
- return c.forEach((d, y) => {
891
- const v = r[y], g = j(v.market);
892
- d.forEach((u) => {
893
- if (u.supply_balance === "0" && u.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
900
+ })).results || [], h = {};
901
+ c.forEach((l, f) => {
902
+ try {
903
+ const w = m[f]?.returnValues?.map((B) => C.vector(ve).parse(Uint8Array.from(B[0])))[0] || [], I = {};
904
+ for (const B of w)
905
+ I[B.id] = {
906
+ supplyIndex: B.supply_index,
907
+ borrowIndex: B.borrow_index
908
+ };
909
+ h[l.key] = I;
910
+ } catch (w) {
911
+ console.warn(
912
+ `[@naviprotocol/lending] Failed to decode reserve data for market "${l.key}", falling back to open-api pool indices`,
913
+ w
914
+ );
915
+ }
916
+ });
917
+ const v = m.slice(c.length).map((l) => l.returnValues?.map((f) => C.vector(we).parse(Uint8Array.from(f[0])))[0] || []), y = [];
918
+ return v.forEach((l, f) => {
919
+ const w = r[f], I = T(w.market), B = h[I.key] || {};
920
+ l.forEach((j) => {
921
+ if (j.supply_balance === "0" && j.borrow_balance === "0" && (w.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
894
922
  return;
895
- const f = s[`${g.key}-${u.asset_id}`];
896
- if (!f)
923
+ const A = s[`${I.key}-${j.asset_id}`];
924
+ if (!A)
897
925
  return;
898
- const k = J(
899
- u.supply_balance,
900
- f.currentSupplyIndex
901
- ).toString(), I = J(
902
- u.borrow_balance,
903
- f.currentBorrowIndex
904
- ).toString();
905
- l.push({
906
- supplyBalance: k,
907
- borrowBalance: I,
908
- assetId: u.asset_id,
909
- market: g.key,
910
- pool: f,
911
- emodeId: v.emodeId
926
+ const L = B[j.asset_id], G = L?.supplyIndex ?? A.currentSupplyIndex, ce = L?.borrowIndex ?? A.currentBorrowIndex, se = Q(j.supply_balance, G).toString(), le = Q(j.borrow_balance, ce).toString();
927
+ y.push({
928
+ supplyBalance: se,
929
+ borrowBalance: le,
930
+ assetId: j.asset_id,
931
+ market: I.key,
932
+ pool: A,
933
+ emodeId: w.emodeId
912
934
  });
913
935
  });
914
- }), l;
936
+ }), y;
915
937
  }
916
- const ct = P(
938
+ const ut = M(
917
939
  async (e, r) => {
918
- const n = (r?.markets || Object.keys(E)).map((t) => j(t)).map((t) => ({
940
+ const n = (r?.markets || Object.keys(U)).map((t) => T(t)).map((t) => ({
919
941
  address: e,
920
942
  market: t.key
921
943
  }));
922
- return await oe(e, n, r);
944
+ return await ne(e, n, r);
923
945
  }
924
946
  );
925
- async function st(e, r) {
926
- const o = r?.client ?? S, n = new F();
927
- await Pe(n, e, r);
947
+ async function pt(e, r) {
948
+ const o = r?.client ?? V, n = new F();
949
+ await Ve(n, e, r);
928
950
  const t = await o.devInspectTransactionBlock({
929
951
  transactionBlock: n,
930
952
  sender: e
931
- }), a = W(t, [C.u256()]);
932
- return x(Number(a[0]) || 0);
953
+ }), a = H(t, [C.u256()]);
954
+ return te(Number(a[0]) || 0);
933
955
  }
934
- async function lt(e, r, o, n) {
935
- const t = n?.client ?? S, a = new F();
956
+ async function dt(e, r, o, n) {
957
+ const t = n?.client ?? V, a = new F();
936
958
  let s = 0, i = 0;
937
- const c = await A(r, n);
959
+ const c = await S(r, n);
938
960
  if (o.forEach((v) => {
939
961
  v.type === R.Supply ? s += v.amount : v.type === R.Withdraw ? s -= v.amount : v.type === R.Borrow ? i += v.amount : v.type === R.Repay && (i -= v.amount);
940
962
  }), s * i < 0)
941
963
  throw new Error("Invalid operations");
942
- const l = s > 0 || i > 0;
943
- await te(
964
+ const u = s > 0 || i > 0;
965
+ await re(
944
966
  a,
945
967
  e,
946
968
  c,
947
969
  Math.abs(s),
948
970
  Math.abs(i),
949
- l,
971
+ u,
950
972
  n
951
973
  );
952
- const d = await t.devInspectTransactionBlock({
974
+ const m = await t.devInspectTransactionBlock({
953
975
  transactionBlock: a,
954
976
  sender: e
955
- }), y = W(d, [C.u256()]);
956
- return x(Number(y[0]) || 0);
977
+ }), h = H(m, [C.u256()]);
978
+ return te(Number(h[0]) || 0);
957
979
  }
958
- const ut = B(
980
+ const mt = P(
959
981
  async (e, r) => {
960
982
  const o = new URLSearchParams();
961
983
  r?.cursor && o.set("cursor", r.cursor), o.set("userAddress", e);
962
- const n = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${V.version}`;
963
- return (await fetch(n, { headers: M }).then((a) => a.json())).data;
984
+ const n = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${E.version}`;
985
+ return (await fetch(n, { headers: D }).then((a) => a.json())).data;
964
986
  }
965
987
  );
966
- async function pt(e, r) {
988
+ async function ft(e, r) {
967
989
  let o = null;
968
- const n = [], t = r?.client ?? S;
990
+ const n = [], t = r?.client ?? V;
969
991
  do {
970
992
  let a;
971
993
  if (r?.coinType ? a = await t.getCoins({
@@ -983,12 +1005,12 @@ async function pt(e, r) {
983
1005
  } while (o);
984
1006
  return n;
985
1007
  }
986
- const $e = P(
1008
+ const Ee = M(
987
1009
  async (e, r) => {
988
- const o = [], n = (r?.markets || Object.keys(E)).map((i) => j(i));
1010
+ const o = [], n = (r?.markets || Object.keys(U)).map((i) => T(i));
989
1011
  let t = [];
990
1012
  try {
991
- t = await ee(e, r);
1013
+ t = await oe(e, r);
992
1014
  } catch (i) {
993
1015
  console.error(i);
994
1016
  }
@@ -998,33 +1020,33 @@ const $e = P(
998
1020
  })).concat(
999
1021
  t.filter((i) => !!n.find((c) => c.id === i.marketId)).map((i) => ({
1000
1022
  address: i.accountCap,
1001
- market: j(i.marketId).key,
1023
+ market: T(i.marketId).key,
1002
1024
  emodeId: i.emodeId
1003
1025
  }))
1004
1026
  );
1005
- return (await oe(e, a, r)).forEach((i) => {
1006
- const c = typeof i.emodeId == "number" ? t.find((l) => {
1007
- const d = j(i.market);
1008
- return l.emodeId === i.emodeId && l.marketId === d.id;
1027
+ return (await ne(e, a, r)).forEach((i) => {
1028
+ const c = typeof i.emodeId == "number" ? t.find((u) => {
1029
+ const m = T(i.market);
1030
+ return u.emodeId === i.emodeId && u.marketId === m.id;
1009
1031
  }) : void 0;
1010
1032
  if (c) {
1011
- if (!i.pool.emodes.find((d) => d.emodeId === c.emodeId))
1033
+ if (!i.pool.emodes.find((m) => m.emodeId === c.emodeId))
1012
1034
  return;
1013
1035
  if (p(i.supplyBalance).gte(0)) {
1014
- const d = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = L(i.pool, c);
1015
- if (d.gt(0) || y.emode.isCollateral)
1036
+ const m = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), h = W(i.pool, c);
1037
+ if (m.gt(0) || h.emode.isCollateral)
1016
1038
  try {
1017
1039
  o.push({
1018
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${T()}`,
1040
+ id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${$()}`,
1019
1041
  wallet: e,
1020
1042
  protocol: "navi",
1021
1043
  market: i.market,
1022
1044
  type: "navi-lending-emode-supply",
1023
1045
  "navi-lending-emode-supply": {
1024
- amount: d.toString(),
1025
- pool: L(i.pool, c),
1046
+ amount: m.toString(),
1047
+ pool: W(i.pool, c),
1026
1048
  token: i.pool.token,
1027
- valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
1049
+ valueUSD: m.multipliedBy(i.pool.oracle.price).toString(),
1028
1050
  emodeCap: c
1029
1051
  }
1030
1052
  });
@@ -1033,20 +1055,20 @@ const $e = P(
1033
1055
  }
1034
1056
  }
1035
1057
  if (p(i.borrowBalance).gte(0)) {
1036
- const d = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = L(i.pool, c);
1037
- if (d.gt(0) || y.emode.isDebt)
1058
+ const m = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), h = W(i.pool, c);
1059
+ if (m.gt(0) || h.emode.isDebt)
1038
1060
  try {
1039
1061
  o.push({
1040
- id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${T()}`,
1062
+ id: `${i.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${$()}`,
1041
1063
  wallet: e,
1042
1064
  protocol: "navi",
1043
1065
  market: i.market,
1044
1066
  type: "navi-lending-emode-borrow",
1045
1067
  "navi-lending-emode-borrow": {
1046
- amount: d.toString(),
1047
- pool: L(i.pool, c),
1068
+ amount: m.toString(),
1069
+ pool: W(i.pool, c),
1048
1070
  token: i.pool.token,
1049
- valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
1071
+ valueUSD: m.multipliedBy(i.pool.oracle.price).toString(),
1050
1072
  emodeCap: c
1051
1073
  }
1052
1074
  });
@@ -1056,34 +1078,34 @@ const $e = P(
1056
1078
  }
1057
1079
  } else {
1058
1080
  if (p(i.supplyBalance).gt(0)) {
1059
- const l = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1081
+ const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1060
1082
  o.push({
1061
- id: `${i.pool.uniqueId}_navi-lending-supply-${T()}`,
1083
+ id: `${i.pool.uniqueId}_navi-lending-supply-${$()}`,
1062
1084
  wallet: e,
1063
1085
  protocol: "navi",
1064
1086
  type: "navi-lending-supply",
1065
1087
  market: i.market,
1066
1088
  "navi-lending-supply": {
1067
- amount: l.toString(),
1089
+ amount: u.toString(),
1068
1090
  pool: i.pool,
1069
1091
  token: i.pool.token,
1070
- valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
1092
+ valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1071
1093
  }
1072
1094
  });
1073
1095
  }
1074
1096
  if (p(i.borrowBalance).gt(0)) {
1075
- const l = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1097
+ const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
1076
1098
  o.push({
1077
- id: `${i.pool.uniqueId}_navi-lending-borrow-${T()}`,
1099
+ id: `${i.pool.uniqueId}_navi-lending-borrow-${$()}`,
1078
1100
  wallet: e,
1079
1101
  protocol: "navi",
1080
1102
  market: i.market,
1081
1103
  type: "navi-lending-borrow",
1082
1104
  "navi-lending-borrow": {
1083
- amount: l.toString(),
1105
+ amount: u.toString(),
1084
1106
  pool: i.pool,
1085
1107
  token: i.pool.token,
1086
- valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
1108
+ valueUSD: u.multipliedBy(i.pool.oracle.price).toString()
1087
1109
  }
1088
1110
  });
1089
1111
  }
@@ -1123,7 +1145,7 @@ class N {
1123
1145
  return this._priceMap = r, this._overview = this.getPositionsOverview(this._positions), this;
1124
1146
  }
1125
1147
  getPrice(r) {
1126
- const o = b(r.suiCoinType);
1148
+ const o = k(r.suiCoinType);
1127
1149
  if (this._priceMap[o] !== void 0)
1128
1150
  return this._priceMap[o].toString();
1129
1151
  const n = r.suiCoinType;
@@ -1143,7 +1165,7 @@ class N {
1143
1165
  const n = !!r.isEMode, t = this.getPrice(r);
1144
1166
  let a;
1145
1167
  return n ? a = {
1146
- id: T(),
1168
+ id: $(),
1147
1169
  wallet: "",
1148
1170
  protocol: "navi",
1149
1171
  market: "",
@@ -1156,7 +1178,7 @@ class N {
1156
1178
  emodeCap: {}
1157
1179
  }
1158
1180
  } : a = {
1159
- id: T(),
1181
+ id: $(),
1160
1182
  wallet: "",
1161
1183
  protocol: "navi",
1162
1184
  market: "",
@@ -1173,7 +1195,7 @@ class N {
1173
1195
  const n = !!r.isEMode, t = this.getPrice(r);
1174
1196
  let a;
1175
1197
  return n ? a = {
1176
- id: T(),
1198
+ id: $(),
1177
1199
  wallet: "",
1178
1200
  protocol: "navi",
1179
1201
  market: "",
@@ -1186,7 +1208,7 @@ class N {
1186
1208
  emodeCap: {}
1187
1209
  }
1188
1210
  } : a = {
1189
- id: T(),
1211
+ id: $(),
1190
1212
  wallet: "",
1191
1213
  protocol: "navi",
1192
1214
  market: "",
@@ -1203,7 +1225,7 @@ class N {
1203
1225
  const n = !!r.isEMode, t = this.getPrice(r);
1204
1226
  let a;
1205
1227
  return n ? a = {
1206
- id: T(),
1228
+ id: $(),
1207
1229
  wallet: "",
1208
1230
  protocol: "navi",
1209
1231
  market: "",
@@ -1216,7 +1238,7 @@ class N {
1216
1238
  emodeCap: {}
1217
1239
  }
1218
1240
  } : a = {
1219
- id: T(),
1241
+ id: $(),
1220
1242
  wallet: "",
1221
1243
  protocol: "navi",
1222
1244
  market: "",
@@ -1233,7 +1255,7 @@ class N {
1233
1255
  const n = !!r.isEMode, t = this.getPrice(r);
1234
1256
  let a;
1235
1257
  return n ? a = {
1236
- id: T(),
1258
+ id: $(),
1237
1259
  wallet: "",
1238
1260
  protocol: "navi",
1239
1261
  market: "",
@@ -1246,7 +1268,7 @@ class N {
1246
1268
  emodeCap: {}
1247
1269
  }
1248
1270
  } : a = {
1249
- id: T(),
1271
+ id: $(),
1250
1272
  wallet: "",
1251
1273
  protocol: "navi",
1252
1274
  market: "",
@@ -1264,74 +1286,74 @@ class N {
1264
1286
  }
1265
1287
  getPositionsOverview(r) {
1266
1288
  const o = {}, n = {};
1267
- let t = new p(0), a = new p(0), s = new p(0), i = new p(0), c = new p(0), l = new p(0);
1268
- r.forEach((g) => {
1269
- if (g.type === "navi-lending-supply") {
1270
- const u = g["navi-lending-supply"], f = this.resolveValueUSD(u);
1289
+ let t = new p(0), a = new p(0), s = new p(0), i = new p(0), c = new p(0), u = new p(0);
1290
+ r.forEach((y) => {
1291
+ if (y.type === "navi-lending-supply") {
1292
+ const l = y["navi-lending-supply"], f = this.resolveValueUSD(l);
1271
1293
  t = t.plus(f), c = c.plus(
1272
- new p(f).multipliedBy(u.pool.liquidationFactor.threshold)
1273
- ), l = l.plus(
1274
- new p(f).multipliedBy(u.pool.ltvValue)
1294
+ new p(f).multipliedBy(l.pool.liquidationFactor.threshold)
1295
+ ), u = u.plus(
1296
+ new p(f).multipliedBy(l.pool.ltvValue)
1275
1297
  );
1276
- } else if (g.type === "navi-lending-borrow") {
1277
- const u = g["navi-lending-borrow"];
1278
- a = a.plus(this.resolveValueUSD(u));
1279
- } else if (g.type === "navi-lending-emode-supply") {
1280
- const u = g["navi-lending-emode-supply"], f = this.resolveValueUSD(u);
1298
+ } else if (y.type === "navi-lending-borrow") {
1299
+ const l = y["navi-lending-borrow"];
1300
+ a = a.plus(this.resolveValueUSD(l));
1301
+ } else if (y.type === "navi-lending-emode-supply") {
1302
+ const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l);
1281
1303
  t = t.plus(f);
1282
- const k = u.pool.emode;
1304
+ const w = l.pool.emode;
1283
1305
  c = c.plus(
1284
- new p(f).multipliedBy(k.lt)
1285
- ), l = l.plus(
1286
- new p(f).multipliedBy(k.ltv)
1306
+ new p(f).multipliedBy(w.lt)
1307
+ ), u = u.plus(
1308
+ new p(f).multipliedBy(w.ltv)
1287
1309
  );
1288
- } else if (g.type === "navi-lending-emode-borrow") {
1289
- const u = g["navi-lending-emode-borrow"];
1290
- a = a.plus(this.resolveValueUSD(u));
1310
+ } else if (y.type === "navi-lending-emode-borrow") {
1311
+ const l = y["navi-lending-emode-borrow"];
1312
+ a = a.plus(this.resolveValueUSD(l));
1291
1313
  }
1292
- }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), l = p.max(l, 0), r.forEach((g) => {
1293
- if (g.type === "navi-lending-supply") {
1294
- const u = g["navi-lending-supply"], f = this.resolveValueUSD(u), k = u.pool.supplyIncentiveApyInfo.apy;
1314
+ }), a = p.max(a, 0), t = p.max(t, 0), c = p.max(c, 0), u = p.max(u, 0), r.forEach((y) => {
1315
+ if (y.type === "navi-lending-supply") {
1316
+ const l = y["navi-lending-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1295
1317
  t.gt(0) && (s = s.plus(
1296
- new p(f).dividedBy(t).multipliedBy(new p(k).dividedBy(100))
1297
- )), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1298
- } else if (g.type === "navi-lending-borrow") {
1299
- const u = g["navi-lending-borrow"], f = this.resolveValueUSD(u), k = u.pool.borrowIncentiveApyInfo.apy;
1318
+ new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
1319
+ )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1320
+ } else if (y.type === "navi-lending-borrow") {
1321
+ const l = y["navi-lending-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1300
1322
  a.gt(0) && (i = i.plus(
1301
- new p(f).dividedBy(a).multipliedBy(new p(k).dividedBy(100))
1302
- )), n[u.pool.suiCoinType] = p(n[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1303
- } else if (g.type === "navi-lending-emode-supply") {
1304
- const u = g["navi-lending-emode-supply"], f = this.resolveValueUSD(u), k = u.pool.supplyIncentiveApyInfo.apy;
1323
+ new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1324
+ )), n[l.pool.suiCoinType] = p(n[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1325
+ } else if (y.type === "navi-lending-emode-supply") {
1326
+ const l = y["navi-lending-emode-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
1305
1327
  t.gt(0) && (s = s.plus(
1306
- new p(f).dividedBy(t).multipliedBy(new p(k).dividedBy(100))
1307
- )), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1308
- } else if (g.type === "navi-lending-emode-borrow") {
1309
- const u = g["navi-lending-emode-borrow"], f = this.resolveValueUSD(u), k = u.pool.borrowIncentiveApyInfo.apy;
1328
+ new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
1329
+ )), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1330
+ } else if (y.type === "navi-lending-emode-borrow") {
1331
+ const l = y["navi-lending-emode-borrow"], f = this.resolveValueUSD(l), w = l.pool.borrowIncentiveApyInfo.apy;
1310
1332
  a.gt(0) && (i = i.plus(
1311
- new p(f).dividedBy(a).multipliedBy(new p(k).dividedBy(100))
1312
- )), n[u.pool.suiCoinType] = p(n[u.pool.suiCoinType] || 0).plus(u.amount).toString();
1333
+ new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
1334
+ )), n[l.pool.suiCoinType] = p(n[l.pool.suiCoinType] || 0).plus(l.amount).toString();
1313
1335
  }
1314
1336
  });
1315
- const d = t.minus(a), y = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(s).minus(a.multipliedBy(i)).div(t.minus(a));
1337
+ const m = t.minus(a), h = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(s).minus(a.multipliedBy(i)).div(t.minus(a));
1316
1338
  return {
1317
1339
  hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
1318
- netVaule: d.toString(),
1319
- netWorthApr: y.toString(),
1340
+ netVaule: m.toString(),
1341
+ netWorthApr: h.toString(),
1320
1342
  totalSupplyValue: t.toString(),
1321
1343
  totalBorrowValue: a.toString(),
1322
1344
  totalsupplyApy: s.toString(),
1323
1345
  totalBorrowApy: i.toString(),
1324
1346
  maxLiquidationValue: c.toString(),
1325
- maxLoanToVaule: l.toString(),
1347
+ maxLoanToVaule: u.toString(),
1326
1348
  supply: o,
1327
1349
  borrow: n
1328
1350
  };
1329
1351
  }
1330
1352
  }
1331
- async function dt(e, r, o, n) {
1353
+ async function yt(e, r, o, n) {
1332
1354
  const t = await _({
1333
1355
  ...n,
1334
- cacheTime: w
1356
+ cacheTime: b
1335
1357
  });
1336
1358
  t.limter && e.moveCall({
1337
1359
  target: `${t.limter}::navi_adaptor::verify_navi_position_healthy`,
@@ -1339,17 +1361,17 @@ async function dt(e, r, o, n) {
1339
1361
  e.object("0x06"),
1340
1362
  e.object(t.storage),
1341
1363
  e.object(t.priceOracle),
1342
- h(r, e.pure.address),
1364
+ g(r, e.pure.address),
1343
1365
  e.pure.u256(new p(o).shiftedBy(27).toNumber())
1344
1366
  ]
1345
1367
  });
1346
1368
  }
1347
- const re = new Q("https://hermes.pyth.network", {
1369
+ const ae = new x("https://hermes.pyth.network", {
1348
1370
  timeout: 1e4
1349
1371
  });
1350
- async function mt(e) {
1372
+ async function gt(e) {
1351
1373
  try {
1352
- const r = [], o = await re.getLatestPriceFeeds(e);
1374
+ const r = [], o = await ae.getLatestPriceFeeds(e);
1353
1375
  if (!o) return r;
1354
1376
  const n = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1355
1377
  for (const t of o) {
@@ -1369,9 +1391,9 @@ async function mt(e) {
1369
1391
  throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
1370
1392
  }
1371
1393
  }
1372
- async function Se(e, r) {
1394
+ async function De(e, r) {
1373
1395
  try {
1374
- const o = [], n = r?.client ?? S, t = e.map((s) => s.priceInfoObject), a = await n.multiGetObjects({
1396
+ const o = [], n = r?.client ?? V, t = e.map((s) => s.priceInfoObject), a = await n.multiGetObjects({
1375
1397
  ids: Array.from(new Set(t)),
1376
1398
  options: { showContent: !0 }
1377
1399
  });
@@ -1381,18 +1403,18 @@ async function Se(e, r) {
1381
1403
  console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
1382
1404
  continue;
1383
1405
  }
1384
- const c = e.find((u) => u.priceInfoObject == i.objectId);
1406
+ const c = e.find((l) => l.priceInfoObject == i.objectId);
1385
1407
  if (!c) {
1386
1408
  console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
1387
1409
  continue;
1388
1410
  }
1389
- const l = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: d, negative: y } = l.price.fields, v = l.conf, g = l.timestamp;
1411
+ const u = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: m, negative: h } = u.price.fields, v = u.conf, y = u.timestamp;
1390
1412
  o.push({
1391
1413
  priceFeedId: c.priceFeedId,
1392
1414
  priceInfoObject: c.priceInfoObject,
1393
- price: y ? "-" + d : d,
1415
+ price: h ? "-" + m : m,
1394
1416
  conf: v,
1395
- publishTime: Number(g),
1417
+ publishTime: Number(y),
1396
1418
  expiration: c.expiration
1397
1419
  });
1398
1420
  }
@@ -1402,9 +1424,9 @@ async function Se(e, r) {
1402
1424
  return;
1403
1425
  }
1404
1426
  }
1405
- async function Ve(e, r) {
1427
+ async function Ue(e, r) {
1406
1428
  try {
1407
- const o = [], n = await Se(e, r);
1429
+ const o = [], n = await De(e, r);
1408
1430
  if (!n) return o;
1409
1431
  const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
1410
1432
  for (const a of n) {
@@ -1424,14 +1446,14 @@ async function Ve(e, r) {
1424
1446
  throw new Error(`failed to get pyth stale price feed id, msg: ${o.message}`);
1425
1447
  }
1426
1448
  }
1427
- async function Me(e, r, o) {
1428
- const n = o?.client ?? S, t = await _({
1449
+ async function Oe(e, r, o) {
1450
+ const n = o?.client ?? V, t = await _({
1429
1451
  ...o,
1430
- cacheTime: w
1452
+ cacheTime: b
1431
1453
  });
1432
1454
  try {
1433
- const a = await re.getPriceFeedsUpdateData(r);
1434
- return await new me(
1455
+ const a = await ae.getPriceFeedsUpdateData(r);
1456
+ return await new ge(
1435
1457
  n,
1436
1458
  t.oracle.pythStateId,
1437
1459
  t.oracle.wormholeStateId
@@ -1440,10 +1462,10 @@ async function Me(e, r, o) {
1440
1462
  throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
1441
1463
  }
1442
1464
  }
1443
- async function Ee(e, r, o) {
1465
+ async function Ne(e, r, o) {
1444
1466
  const n = await _({
1445
1467
  ...o,
1446
- cacheTime: w
1468
+ cacheTime: b
1447
1469
  });
1448
1470
  if (o?.updatePythPriceFeeds) {
1449
1471
  const t = r.filter((a) => !!a.pythPriceFeedId && !!a.pythPriceInfoObject).map((a) => ({
@@ -1452,8 +1474,8 @@ async function Ee(e, r, o) {
1452
1474
  expiration: 30
1453
1475
  }));
1454
1476
  try {
1455
- const a = await Ve(t, o);
1456
- a.length > 0 && await Me(e, a, o);
1477
+ const a = await Ue(t, o);
1478
+ a.length > 0 && await Oe(e, a, o);
1457
1479
  } catch {
1458
1480
  console.error("Failed to update Pyth price feeds");
1459
1481
  }
@@ -1495,13 +1517,13 @@ async function Ee(e, r, o) {
1495
1517
  });
1496
1518
  return e;
1497
1519
  }
1498
- async function ne(e) {
1520
+ async function ie(e) {
1499
1521
  return (await _({
1500
1522
  ...e,
1501
- cacheTime: w
1523
+ cacheTime: b
1502
1524
  })).oracle.feeds;
1503
1525
  }
1504
- function De(e, r) {
1526
+ function Fe(e, r) {
1505
1527
  return e.filter((o) => !!(r?.lendingState && r.lendingState.find((t) => o.oracleId === t.pool.oracleId) || r?.lendingPositions && r.lendingPositions.find((t) => {
1506
1528
  if (![
1507
1529
  "navi-lending-supply",
@@ -1514,22 +1536,22 @@ function De(e, r) {
1514
1536
  return o.oracleId === s?.oracleId;
1515
1537
  }) || r?.pools && r.pools.find((t) => o.oracleId === t.oracleId)));
1516
1538
  }
1517
- async function ft(e, r, o, n) {
1539
+ async function ht(e, r, o, n) {
1518
1540
  try {
1519
- const t = await ne({
1541
+ const t = await ie({
1520
1542
  ...n
1521
1543
  }), a = [];
1522
- o.forEach((l) => {
1523
- a.includes(l.market) || a.push(l.market);
1544
+ o.forEach((u) => {
1545
+ a.includes(u.market) || a.push(u.market);
1524
1546
  });
1525
- const s = await $e(r, {
1547
+ const s = await Ee(r, {
1526
1548
  ...n,
1527
1549
  markets: a
1528
- }), i = De(t, {
1550
+ }), i = Fe(t, {
1529
1551
  lendingPositions: s,
1530
1552
  pools: o
1531
1553
  });
1532
- return await Ee(e, i, {
1554
+ return await Ne(e, i, {
1533
1555
  updatePythPriceFeeds: !0,
1534
1556
  ...n
1535
1557
  });
@@ -1539,10 +1561,10 @@ async function ft(e, r, o, n) {
1539
1561
  return console.error(t), e;
1540
1562
  }
1541
1563
  }
1542
- const z = P(
1543
- B(
1564
+ const Y = M(
1565
+ P(
1544
1566
  async (e) => {
1545
- const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || U}`, o = await fetch(r, { headers: M }).then((n) => n.json());
1567
+ const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${E.version}&market=${e?.market || O}`, o = await fetch(r, { headers: D }).then((n) => n.json());
1546
1568
  return Object.keys(o.data).map((n) => ({
1547
1569
  ...o.data[n],
1548
1570
  coinType: n
@@ -1550,78 +1572,78 @@ const z = P(
1550
1572
  }
1551
1573
  )
1552
1574
  );
1553
- async function yt(e, r) {
1554
- return (await z(r)).find((n) => typeof e == "string" ? b(n.coinType) === b(e) : typeof e == "number" ? n.assetId === e : n.assetId === e.id) || null;
1575
+ async function vt(e, r) {
1576
+ return (await Y(r)).find((n) => typeof e == "string" ? k(n.coinType) === k(e) : typeof e == "number" ? n.assetId === e : n.assetId === e.id) || null;
1555
1577
  }
1556
- async function gt(e, r, o, n) {
1578
+ async function wt(e, r, o, n) {
1557
1579
  const t = await _({
1558
1580
  ...n,
1559
- cacheTime: w
1560
- }), a = await A(r, n);
1561
- if (!(await z({
1581
+ cacheTime: b
1582
+ }), a = await S(r, n);
1583
+ if (!(await Y({
1562
1584
  ...n,
1563
- cacheTime: w
1585
+ cacheTime: b
1564
1586
  })).some(
1565
- (c) => b(c.coinType) === b(a.suiCoinType)
1587
+ (c) => k(c.coinType) === k(a.suiCoinType)
1566
1588
  ))
1567
1589
  throw new Error("Pool does not support flashloan");
1568
1590
  if (t.version === 1) {
1569
- const [c, l] = e.moveCall({
1591
+ const [c, u] = e.moveCall({
1570
1592
  target: `${t.package}::lending::flash_loan_with_ctx`,
1571
1593
  arguments: [
1572
1594
  e.object(t.flashloanConfig),
1573
1595
  e.object(a.contract.pool),
1574
- h(o, e.pure.u64)
1596
+ g(o, e.pure.u64)
1575
1597
  ],
1576
1598
  typeArguments: [a.suiCoinType]
1577
1599
  });
1578
- return [c, l];
1600
+ return [c, u];
1579
1601
  } else {
1580
- const [c, l] = e.moveCall({
1602
+ const [c, u] = e.moveCall({
1581
1603
  target: `${t.package}::lending::flash_loan_with_ctx_v2`,
1582
1604
  arguments: [
1583
1605
  e.object(t.flashloanConfig),
1584
1606
  e.object(a.contract.pool),
1585
- h(o, e.pure.u64),
1607
+ g(o, e.pure.u64),
1586
1608
  e.object("0x05")
1587
1609
  ],
1588
1610
  typeArguments: [a.suiCoinType]
1589
1611
  });
1590
- return [c, l];
1612
+ return [c, u];
1591
1613
  }
1592
1614
  }
1593
- async function ht(e, r, o, n, t) {
1615
+ async function bt(e, r, o, n, t) {
1594
1616
  const a = await _({
1595
1617
  ...t,
1596
- cacheTime: w
1597
- }), s = await A(r, t);
1598
- if (!(await z({
1618
+ cacheTime: b
1619
+ }), s = await S(r, t);
1620
+ if (!(await Y({
1599
1621
  ...t,
1600
- cacheTime: w
1622
+ cacheTime: b
1601
1623
  })).some(
1602
- (d) => b(d.coinType) === b(s.suiCoinType)
1624
+ (m) => k(m.coinType) === k(s.suiCoinType)
1603
1625
  ))
1604
1626
  throw new Error("Pool does not support flashloan");
1605
- const [l] = e.moveCall({
1627
+ const [u] = e.moveCall({
1606
1628
  target: `${a.package}::lending::flash_repay_with_ctx`,
1607
1629
  arguments: [
1608
1630
  e.object("0x06"),
1609
1631
  e.object(a.storage),
1610
1632
  e.object(s.contract.pool),
1611
- h(o, e.object),
1612
- h(n, e.object)
1633
+ g(o, e.object),
1634
+ g(n, e.object)
1613
1635
  ],
1614
1636
  typeArguments: [s.suiCoinType]
1615
1637
  });
1616
- return [l];
1638
+ return [u];
1617
1639
  }
1618
- async function vt(e, r, o, n, t, a) {
1640
+ async function kt(e, r, o, n, t, a) {
1619
1641
  const s = {
1620
1642
  ...a,
1621
- cacheTime: w
1622
- }, i = await _(s), c = await A(r, s), l = await A(n, s);
1643
+ cacheTime: b
1644
+ }, i = await _(s), c = await S(r, s), u = await S(n, s);
1623
1645
  if (i.version === 1) {
1624
- const [d, y] = e.moveCall({
1646
+ const [m, h] = e.moveCall({
1625
1647
  target: `${i.package}::incentive_v3::liquidation`,
1626
1648
  arguments: [
1627
1649
  e.object("0x06"),
@@ -1634,24 +1656,24 @@ async function vt(e, r, o, n, t, a) {
1634
1656
  // Pay asset ID
1635
1657
  e.object(c.contract.pool),
1636
1658
  // Pay asset pool contract
1637
- h(o, e.object),
1659
+ g(o, e.object),
1638
1660
  // Debt repayment amount
1639
- e.pure.u8(l.id),
1661
+ e.pure.u8(u.id),
1640
1662
  // Collateral asset ID
1641
- e.object(l.contract.pool),
1663
+ e.object(u.contract.pool),
1642
1664
  // Collateral asset pool contract
1643
- h(t, e.pure.address),
1665
+ g(t, e.pure.address),
1644
1666
  // Borrower address
1645
1667
  e.object(i.incentiveV2),
1646
1668
  // Incentive V2 contract
1647
1669
  e.object(i.incentiveV3)
1648
1670
  // Incentive V3 contract
1649
1671
  ],
1650
- typeArguments: [c.suiCoinType, l.suiCoinType]
1672
+ typeArguments: [c.suiCoinType, u.suiCoinType]
1651
1673
  });
1652
- return [d, y];
1674
+ return [m, h];
1653
1675
  } else {
1654
- const [d, y] = e.moveCall({
1676
+ const [m, h] = e.moveCall({
1655
1677
  target: `${i.package}::incentive_v3::liquidation_v2`,
1656
1678
  arguments: [
1657
1679
  e.object("0x06"),
@@ -1664,13 +1686,13 @@ async function vt(e, r, o, n, t, a) {
1664
1686
  // Pay asset ID
1665
1687
  e.object(c.contract.pool),
1666
1688
  // Pay asset pool contract
1667
- h(o, e.object),
1689
+ g(o, e.object),
1668
1690
  // Debt repayment amount
1669
- e.pure.u8(l.id),
1691
+ e.pure.u8(u.id),
1670
1692
  // Collateral asset ID
1671
- e.object(l.contract.pool),
1693
+ e.object(u.contract.pool),
1672
1694
  // Collateral asset pool contract
1673
- h(t, e.pure.address),
1695
+ g(t, e.pure.address),
1674
1696
  // Borrower address
1675
1697
  e.object(i.incentiveV2),
1676
1698
  // Incentive V2 contract
@@ -1679,33 +1701,33 @@ async function vt(e, r, o, n, t, a) {
1679
1701
  e.object("0x05")
1680
1702
  // SuiSystemState object
1681
1703
  ],
1682
- typeArguments: [c.suiCoinType, l.suiCoinType]
1704
+ typeArguments: [c.suiCoinType, u.suiCoinType]
1683
1705
  });
1684
- return [d, y];
1706
+ return [m, h];
1685
1707
  }
1686
1708
  }
1687
- async function Ue(e, r, o) {
1688
- const n = o?.client ?? S, t = new F(), a = await q({
1709
+ async function Re(e, r, o) {
1710
+ const n = o?.client ?? V, t = new F(), a = await q({
1689
1711
  ...o,
1690
- markets: Object.values(E),
1691
- cacheTime: w
1692
- }), s = await ne(o);
1693
- for (let d of r) {
1694
- const y = await _({
1712
+ markets: Object.values(U),
1713
+ cacheTime: b
1714
+ }), s = await ie(o);
1715
+ for (let m of r) {
1716
+ const h = await _({
1695
1717
  ...o,
1696
- cacheTime: w,
1697
- market: d.market
1718
+ cacheTime: b,
1719
+ market: m.market
1698
1720
  });
1699
1721
  t.moveCall({
1700
- target: `${y.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
1722
+ target: `${h.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
1701
1723
  arguments: [
1702
1724
  t.object("0x06"),
1703
1725
  // Clock object
1704
- t.object(y.storage),
1726
+ t.object(h.storage),
1705
1727
  // Protocol storage
1706
- t.object(y.incentiveV3),
1728
+ t.object(h.incentiveV3),
1707
1729
  // Incentive V3 contract
1708
- t.pure.address(d.address)
1730
+ t.pure.address(m.address)
1709
1731
  // User address
1710
1732
  ]
1711
1733
  });
@@ -1714,11 +1736,11 @@ async function Ue(e, r, o) {
1714
1736
  transactionBlock: t,
1715
1737
  sender: e
1716
1738
  }), c = [];
1717
- i?.results?.forEach((d) => {
1739
+ i?.results?.forEach((m) => {
1718
1740
  c.push(
1719
- W(
1741
+ H(
1720
1742
  {
1721
- results: [d]
1743
+ results: [m]
1722
1744
  },
1723
1745
  [
1724
1746
  C.vector(C.string()),
@@ -1735,24 +1757,24 @@ async function Ue(e, r, o) {
1735
1757
  )
1736
1758
  );
1737
1759
  });
1738
- const l = [];
1739
- return c.forEach((d, y) => {
1740
- const v = r[y];
1741
- if (d.length === 5 && Array.isArray(d[0])) {
1742
- const g = d[0].length;
1743
- for (let u = 0; u < g; u++) {
1760
+ const u = [];
1761
+ return c.forEach((m, h) => {
1762
+ const v = r[h];
1763
+ if (m.length === 5 && Array.isArray(m[0])) {
1764
+ const y = m[0].length;
1765
+ for (let l = 0; l < y; l++) {
1744
1766
  const f = s.find(
1745
- (I) => b(I.coinType) === b(d[1][u])
1746
- ), k = a.find(
1747
- (I) => b(I.coinType) === b(d[0][u]) && I.market === v.market
1767
+ (I) => k(I.coinType) === k(m[1][l])
1768
+ ), w = a.find(
1769
+ (I) => k(I.coinType) === k(m[0][l]) && I.market === v.market
1748
1770
  );
1749
- !f || !k || l.push({
1750
- assetId: k.id,
1751
- assetCoinType: b(d[0][u]),
1752
- rewardCoinType: b(d[1][u]),
1753
- option: Number(d[2][u]),
1754
- userClaimableReward: Number(d[4][u]) / Math.pow(10, f.priceDecimal),
1755
- ruleIds: Array.isArray(d[3][u]) ? d[3][u] : [d[3][u]],
1771
+ !f || !w || u.push({
1772
+ assetId: w.id,
1773
+ assetCoinType: k(m[0][l]),
1774
+ rewardCoinType: k(m[1][l]),
1775
+ option: Number(m[2][l]),
1776
+ userClaimableReward: Number(m[4][l]) / Math.pow(10, f.priceDecimal),
1777
+ ruleIds: Array.isArray(m[3][l]) ? m[3][l] : [m[3][l]],
1756
1778
  market: v.market,
1757
1779
  owner: v.owner,
1758
1780
  address: v.address,
@@ -1760,13 +1782,13 @@ async function Ue(e, r, o) {
1760
1782
  });
1761
1783
  }
1762
1784
  }
1763
- }), l;
1785
+ }), u;
1764
1786
  }
1765
- async function wt(e, r) {
1766
- const o = (r?.markets || [E.main]).map((a) => j(a));
1787
+ async function _t(e, r) {
1788
+ const o = (r?.markets || [U.main]).map((a) => T(a));
1767
1789
  let n = [];
1768
1790
  try {
1769
- n = await ee(e, r);
1791
+ n = await oe(e, r);
1770
1792
  } catch (a) {
1771
1793
  console.error(a);
1772
1794
  }
@@ -1776,7 +1798,7 @@ async function wt(e, r) {
1776
1798
  market: a.key
1777
1799
  })).concat(
1778
1800
  n.filter((a) => !!o.find((s) => s.id === a.marketId)).map((a) => {
1779
- const s = j(a.marketId);
1801
+ const s = T(a.marketId);
1780
1802
  return {
1781
1803
  address: a.accountCap,
1782
1804
  owner: e,
@@ -1785,9 +1807,9 @@ async function wt(e, r) {
1785
1807
  };
1786
1808
  })
1787
1809
  );
1788
- return await Ue(e, t, r);
1810
+ return await Re(e, t, r);
1789
1811
  }
1790
- function bt(e) {
1812
+ function Ct(e) {
1791
1813
  const r = /* @__PURE__ */ new Map();
1792
1814
  e.forEach((n) => {
1793
1815
  const t = n.assetId, a = n.option, s = `${t}-${a}-${n.rewardCoinType}-${n.market}`;
@@ -1803,8 +1825,8 @@ function bt(e) {
1803
1825
  for (const { assetId: n, rewardType: t, coinType: a, total: s, market: i } of r.values()) {
1804
1826
  const c = `${n}-${t}-${i}`;
1805
1827
  o.has(c) || o.set(c, { assetId: n, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
1806
- const l = o.get(c);
1807
- l.rewards.set(a, (l.rewards.get(a) || 0) + s);
1828
+ const u = o.get(c);
1829
+ u.rewards.set(a, (u.rewards.get(a) || 0) + s);
1808
1830
  }
1809
1831
  return Array.from(o.values()).map((n) => ({
1810
1832
  assetId: n.assetId,
@@ -1816,109 +1838,109 @@ function bt(e) {
1816
1838
  }))
1817
1839
  }));
1818
1840
  }
1819
- const kt = B(
1841
+ const jt = P(
1820
1842
  async (e, r) => {
1821
- const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${r?.market || U}`;
1822
- return (await fetch(o, { headers: M }).then((t) => t.json())).data;
1843
+ const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${E.version}&market=${r?.market || O}`;
1844
+ return (await fetch(o, { headers: D }).then((t) => t.json())).data;
1823
1845
  }
1824
- ), _t = B(
1846
+ ), It = P(
1825
1847
  async (e, r) => {
1826
- const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${r?.page || 1}&pageSize=${r?.size || 400}&sdk=${V.version}&market=${r?.market || U}`, n = await fetch(o, { headers: M }).then((t) => t.json());
1827
- return H({
1848
+ const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${r?.page || 1}&pageSize=${r?.size || 400}&sdk=${E.version}&market=${r?.market || O}`, n = await fetch(o, { headers: D }).then((t) => t.json());
1849
+ return K({
1828
1850
  data: n.data.rewards
1829
1851
  });
1830
1852
  }
1831
1853
  );
1832
- async function Ct(e, r, o) {
1854
+ async function Tt(e, r, o) {
1833
1855
  const n = await q({
1834
1856
  ...o,
1835
- markets: Object.values(E),
1836
- cacheTime: w
1857
+ markets: Object.values(U),
1858
+ cacheTime: b
1837
1859
  }), t = /* @__PURE__ */ new Map();
1838
1860
  for (const s of r) {
1839
- const { rewardCoinType: i, ruleIds: c, market: l, owner: d, address: y, emodeId: v } = s, g = `${i}___${y}__${l}`;
1840
- for (const u of c) {
1841
- t.has(g) || t.set(g, {
1861
+ const { rewardCoinType: i, ruleIds: c, market: u, owner: m, address: h, emodeId: v } = s, y = `${i}___${h}__${u}`;
1862
+ for (const l of c) {
1863
+ t.has(y) || t.set(y, {
1842
1864
  assetIds: [],
1843
1865
  ruleIds: [],
1844
1866
  amount: 0,
1845
- market: l,
1846
- owner: d,
1847
- address: y,
1867
+ market: u,
1868
+ owner: m,
1869
+ address: h,
1848
1870
  isEMode: typeof v < "u"
1849
1871
  });
1850
- const f = t.get(g);
1851
- f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(u), f.amount += s.userClaimableReward;
1872
+ const f = t.get(y);
1873
+ f.assetIds.push(s.assetCoinType.replace("0x", "")), f.ruleIds.push(l), f.amount += s.userClaimableReward;
1852
1874
  }
1853
1875
  }
1854
1876
  const a = [];
1855
1877
  for (const [
1856
1878
  s,
1857
- { assetIds: i, ruleIds: c, amount: l, market: d, owner: y, address: v, isEMode: g }
1879
+ { assetIds: i, ruleIds: c, amount: u, market: m, owner: h, address: v, isEMode: y }
1858
1880
  ] of t) {
1859
- const u = await _({
1881
+ const l = await _({
1860
1882
  ...o,
1861
- cacheTime: w,
1862
- market: d
1863
- }), f = s.split("___")[0], k = n.filter(
1864
- ($) => b($.suiCoinType) === b(f)
1883
+ cacheTime: b,
1884
+ market: m
1885
+ }), f = s.split("___")[0], w = n.filter(
1886
+ (j) => k(j.suiCoinType) === k(f)
1865
1887
  );
1866
- k.sort(($, D) => $.market === d ? -1 : 1);
1867
- const I = k[0], O = u.rewardFunds[b(f)];
1868
- if (!O)
1869
- throw new Error(`No matching rewardFund found for reward coin: ${f} ${d}`);
1888
+ w.sort((j, A) => j.market === m ? -1 : 1);
1889
+ const I = w[0], B = l.rewardFunds[k(f)];
1890
+ if (!B)
1891
+ throw new Error(`No matching rewardFund found for reward coin: ${f} ${m}`);
1870
1892
  if (o?.accountCap && !o.customCoinReceive)
1871
1893
  throw new Error("customCoinReceive is required when accountCap is provided");
1872
1894
  if (o?.customCoinReceive) {
1873
- let $;
1874
- o.accountCap ? $ = e.moveCall({
1875
- target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1895
+ let j;
1896
+ o.accountCap ? j = e.moveCall({
1897
+ target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1876
1898
  arguments: [
1877
1899
  e.object("0x06"),
1878
1900
  // Clock object
1879
- e.object(u.incentiveV3),
1901
+ e.object(l.incentiveV3),
1880
1902
  // Incentive V3 contract
1881
- e.object(u.storage),
1903
+ e.object(l.storage),
1882
1904
  // Protocol storage
1883
- e.object(O),
1905
+ e.object(B),
1884
1906
  // Reward fund
1885
1907
  e.pure.vector("string", i),
1886
1908
  // Asset IDs
1887
1909
  e.pure.vector("address", c),
1888
1910
  // Rule IDs
1889
- h(o.accountCap, e.object)
1911
+ g(o.accountCap, e.object)
1890
1912
  // Account capability
1891
1913
  ],
1892
1914
  typeArguments: [f]
1893
- }) : g ? $ = e.moveCall({
1894
- target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1915
+ }) : y ? j = e.moveCall({
1916
+ target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1895
1917
  arguments: [
1896
1918
  e.object("0x06"),
1897
1919
  // Clock object
1898
- e.object(u.incentiveV3),
1920
+ e.object(l.incentiveV3),
1899
1921
  // Incentive V3 contract
1900
- e.object(u.storage),
1922
+ e.object(l.storage),
1901
1923
  // Protocol storage
1902
- e.object(O),
1924
+ e.object(B),
1903
1925
  // Reward fund
1904
1926
  e.pure.vector("string", i),
1905
1927
  // Asset IDs
1906
1928
  e.pure.vector("address", c),
1907
1929
  // Rule IDs
1908
- h(v, e.object)
1930
+ g(v, e.object)
1909
1931
  // Account capability
1910
1932
  ],
1911
1933
  typeArguments: [f]
1912
- }) : $ = e.moveCall({
1913
- target: `${u.package}::incentive_v3::claim_reward`,
1934
+ }) : j = e.moveCall({
1935
+ target: `${l.package}::incentive_v3::claim_reward`,
1914
1936
  arguments: [
1915
1937
  e.object("0x06"),
1916
1938
  // Clock object
1917
- e.object(u.incentiveV3),
1939
+ e.object(l.incentiveV3),
1918
1940
  // Incentive V3 contract
1919
- e.object(u.storage),
1941
+ e.object(l.storage),
1920
1942
  // Protocol storage
1921
- e.object(O),
1943
+ e.object(B),
1922
1944
  // Reward fund
1923
1945
  e.pure.vector("string", i),
1924
1946
  // Asset IDs
@@ -1927,75 +1949,75 @@ async function Ct(e, r, o) {
1927
1949
  ],
1928
1950
  typeArguments: [f]
1929
1951
  });
1930
- const [D] = e.moveCall({
1952
+ const [A] = e.moveCall({
1931
1953
  target: "0x2::coin::from_balance",
1932
- arguments: [$],
1954
+ arguments: [j],
1933
1955
  typeArguments: [f]
1934
1956
  });
1935
1957
  if (o?.customCoinReceive.type === "transfer") {
1936
1958
  if (!o.customCoinReceive.transfer)
1937
1959
  throw new Error("customCoinReceive.transfer is required");
1938
1960
  e.transferObjects(
1939
- [D],
1940
- h(o.customCoinReceive.transfer, e.pure.address)
1961
+ [A],
1962
+ g(o.customCoinReceive.transfer, e.pure.address)
1941
1963
  );
1942
1964
  }
1943
1965
  if (o?.customCoinReceive.type === "depositNAVI") {
1944
- const ae = p(I.totalSupplyAmount).shiftedBy(-9), ie = p(I.supplyCapCeiling).shiftedBy(-27);
1945
- ae.plus(l).isGreaterThan(ie) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
1946
- [D],
1966
+ const L = p(I.totalSupplyAmount).shiftedBy(-9), G = p(I.supplyCapCeiling).shiftedBy(-27);
1967
+ L.plus(u).isGreaterThan(G) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
1968
+ [A],
1947
1969
  e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
1948
- ) : await Ce(e, I, D, {
1970
+ ) : await Be(e, I, A, {
1949
1971
  ...o,
1950
1972
  market: I.market
1951
1973
  });
1952
1974
  } else
1953
1975
  a.push({
1954
- coin: D,
1976
+ coin: A,
1955
1977
  identifier: I,
1956
- owner: y,
1957
- isEMode: g
1978
+ owner: h,
1979
+ isEMode: y
1958
1980
  });
1959
- } else if (o?.accountCap || g) {
1960
- const $ = e.moveCall({
1961
- target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
1981
+ } else if (o?.accountCap || y) {
1982
+ const j = e.moveCall({
1983
+ target: `${l.package}::incentive_v3::claim_reward_with_account_cap`,
1962
1984
  arguments: [
1963
1985
  e.object("0x06"),
1964
1986
  // Clock object
1965
- e.object(u.incentiveV3),
1987
+ e.object(l.incentiveV3),
1966
1988
  // Incentive V3 contract
1967
- e.object(u.storage),
1989
+ e.object(l.storage),
1968
1990
  // Protocol storage
1969
- e.object(O),
1991
+ e.object(B),
1970
1992
  // Reward fund
1971
1993
  e.pure.vector("string", i),
1972
1994
  // Asset IDs
1973
1995
  e.pure.vector("address", c),
1974
1996
  // Rule IDs
1975
- h(o?.accountCap || v, e.object)
1997
+ g(o?.accountCap || v, e.object)
1976
1998
  // Account capability
1977
1999
  ],
1978
2000
  typeArguments: [f]
1979
- }), [D] = e.moveCall({
2001
+ }), [A] = e.moveCall({
1980
2002
  target: "0x2::coin::from_balance",
1981
- arguments: [$],
2003
+ arguments: [j],
1982
2004
  typeArguments: [f]
1983
2005
  });
1984
2006
  e.transferObjects(
1985
- [D],
1986
- h(o?.accountCap || y, e.pure.address)
2007
+ [A],
2008
+ g(o?.accountCap || h, e.pure.address)
1987
2009
  );
1988
2010
  } else
1989
2011
  e.moveCall({
1990
- target: `${u.package}::incentive_v3::claim_reward_entry`,
2012
+ target: `${l.package}::incentive_v3::claim_reward_entry`,
1991
2013
  arguments: [
1992
2014
  e.object("0x06"),
1993
2015
  // Clock object
1994
- e.object(u.incentiveV3),
2016
+ e.object(l.incentiveV3),
1995
2017
  // Incentive V3 contract
1996
- e.object(u.storage),
2018
+ e.object(l.storage),
1997
2019
  // Protocol storage
1998
- e.object(O),
2020
+ e.object(B),
1999
2021
  // Reward fund
2000
2022
  e.pure.vector("string", i),
2001
2023
  // Asset IDs
@@ -2008,71 +2030,71 @@ async function Ct(e, r, o) {
2008
2030
  return a;
2009
2031
  }
2010
2032
  export {
2011
- K as Address,
2012
- w as DEFAULT_CACHE_TIME,
2013
- U as DEFAULT_MARKET_IDENTITY,
2014
- Ye as FlashLoanAssetConfig,
2015
- Ge as IncentiveAPYInfo,
2016
- fe as IncentivePoolInfo,
2017
- ze as IncentivePoolInfoByPhase,
2018
- E as MARKETS,
2019
- je as Market,
2020
- Ke as OracleInfo,
2033
+ J as Address,
2034
+ b as DEFAULT_CACHE_TIME,
2035
+ O as DEFAULT_MARKET_IDENTITY,
2036
+ Xe as FlashLoanAssetConfig,
2037
+ Je as IncentiveAPYInfo,
2038
+ he as IncentivePoolInfo,
2039
+ Ze as IncentivePoolInfoByPhase,
2040
+ U as MARKETS,
2041
+ Ae as Market,
2042
+ Qe as OracleInfo,
2021
2043
  R as PoolOperator,
2022
- Je as ReserveDataInfo,
2044
+ ve as ReserveDataInfo,
2023
2045
  N as UserPositions,
2024
- ye as UserStateInfo,
2025
- xe as borrowCoinPTB,
2026
- Ct as claimLendingRewardsPTB,
2027
- Te as createAccountCapPTB,
2028
- nt as createEModeCapPTB,
2029
- Ce as depositCoinPTB,
2030
- at as emodeIdentityId,
2031
- Ae as enterEModePTB,
2032
- rt as exitEModePTB,
2033
- De as filterPriceFeeds,
2034
- gt as flashloanPTB,
2035
- Be as getAccountCapOwnerPTB,
2036
- z as getAllFlashLoanAssets,
2037
- tt as getBorrowFee,
2038
- pt as getCoins,
2046
+ we as UserStateInfo,
2047
+ ot as borrowCoinPTB,
2048
+ Tt as claimLendingRewardsPTB,
2049
+ Pe as createAccountCapPTB,
2050
+ ct as createEModeCapPTB,
2051
+ Be as depositCoinPTB,
2052
+ st as emodeIdentityId,
2053
+ Me as enterEModePTB,
2054
+ it as exitEModePTB,
2055
+ Fe as filterPriceFeeds,
2056
+ wt as flashloanPTB,
2057
+ Se as getAccountCapOwnerPTB,
2058
+ Y as getAllFlashLoanAssets,
2059
+ nt as getBorrowFee,
2060
+ ft as getCoins,
2039
2061
  _ as getConfig,
2040
- Qe as getFees,
2041
- yt as getFlashLoanAsset,
2042
- st as getHealthFactor,
2043
- Pe as getHealthFactorPTB,
2044
- $e as getLendingPositions,
2045
- ct as getLendingState,
2046
- ot as getMarket,
2047
- j as getMarketConfig,
2048
- Ie as getMarkets,
2049
- A as getPool,
2062
+ et as getFees,
2063
+ vt as getFlashLoanAsset,
2064
+ pt as getHealthFactor,
2065
+ Ve as getHealthFactorPTB,
2066
+ Ee as getLendingPositions,
2067
+ ut as getLendingState,
2068
+ at as getMarket,
2069
+ T as getMarketConfig,
2070
+ $e as getMarkets,
2071
+ S as getPool,
2050
2072
  q as getPools,
2051
- ne as getPriceFeeds,
2052
- mt as getPythStalePriceFeedId,
2053
- Ve as getPythStalePriceFeedIdV2,
2054
- lt as getSimulatedHealthFactor,
2055
- te as getSimulatedHealthFactorPTB,
2056
- Ze as getStats,
2057
- ut as getTransactions,
2058
- wt as getUserAvailableLendingRewards,
2059
- _t as getUserClaimedRewardHistory,
2060
- ee as getUserEModeCaps,
2061
- kt as getUserTotalClaimedReward,
2062
- vt as liquidatePTB,
2063
- it as mergeCoinsPTB,
2064
- b as normalizeCoinType,
2065
- _e as parsePoolUID,
2066
- h as parseTxValue,
2067
- et as repayCoinPTB,
2068
- ht as repayFlashLoanPTB,
2069
- bt as summaryLendingRewards,
2070
- ft as updateOraclePriceBeforeUserOperationPTB,
2071
- Ee as updateOraclePricesPTB,
2072
- Me as updatePythPriceFeeds,
2073
- dt as verifyHealthFactorPTB,
2074
- P as withCache,
2075
- B as withSingleton,
2076
- Xe as withdrawCoinPTB
2073
+ ie as getPriceFeeds,
2074
+ gt as getPythStalePriceFeedId,
2075
+ Ue as getPythStalePriceFeedIdV2,
2076
+ dt as getSimulatedHealthFactor,
2077
+ re as getSimulatedHealthFactorPTB,
2078
+ xe as getStats,
2079
+ mt as getTransactions,
2080
+ _t as getUserAvailableLendingRewards,
2081
+ It as getUserClaimedRewardHistory,
2082
+ oe as getUserEModeCaps,
2083
+ jt as getUserTotalClaimedReward,
2084
+ kt as liquidatePTB,
2085
+ lt as mergeCoinsPTB,
2086
+ k as normalizeCoinType,
2087
+ Te as parsePoolUID,
2088
+ g as parseTxValue,
2089
+ rt as repayCoinPTB,
2090
+ bt as repayFlashLoanPTB,
2091
+ Ct as summaryLendingRewards,
2092
+ ht as updateOraclePriceBeforeUserOperationPTB,
2093
+ Ne as updateOraclePricesPTB,
2094
+ Oe as updatePythPriceFeeds,
2095
+ yt as verifyHealthFactorPTB,
2096
+ M as withCache,
2097
+ P as withSingleton,
2098
+ tt as withdrawCoinPTB
2077
2099
  };
2078
2100
  //# sourceMappingURL=index.esm.js.map