@naviprotocol/lending 1.3.0-dev.7 → 1.3.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,27 +1,27 @@
1
- import { Transaction as k } from "@mysten/sui/transactions";
2
- import { bcs as i, toHex as G, fromHex as H } from "@mysten/bcs";
3
- import { SuiClient as q, getFullnodeUrl as z } from "@mysten/sui/client";
4
- import W from "lodash.camelcase";
5
- import { normalizeStructTag as J } from "@mysten/sui/utils";
6
- import { SuiPriceServiceConnection as N, SuiPythClient as K } from "@pythnetwork/pyth-sui-js";
1
+ import { Transaction as B } from "@mysten/sui/transactions";
2
+ import { bcs as i, toHex as z, fromHex as W } from "@mysten/bcs";
3
+ import { SuiClient as J, getFullnodeUrl as K } from "@mysten/sui/client";
4
+ import Y from "lodash.camelcase";
5
+ import { normalizeStructTag as Q } from "@mysten/sui/utils";
6
+ import { SuiPriceServiceConnection as U, SuiPythClient as X } from "@pythnetwork/pyth-sui-js";
7
7
  import T from "bignumber.js";
8
8
  import { bcs as h } from "@mysten/sui/bcs";
9
- const F = i.bytes(32).transform({
9
+ const R = i.bytes(32).transform({
10
10
  // To change the input type, you need to provide a type definition for the input
11
- input: (e) => H(e),
12
- output: (e) => G(e)
13
- }), fe = i.struct("IncentiveAPYInfo", {
11
+ input: (e) => W(e),
12
+ output: (e) => z(e)
13
+ }), he = i.struct("IncentiveAPYInfo", {
14
14
  /** Asset identifier */
15
15
  asset_id: i.u8(),
16
16
  /** Annual Percentage Yield as a 256-bit integer */
17
17
  apy: i.u256(),
18
18
  /** List of supported coin types for this incentive */
19
19
  coin_types: i.vector(i.string())
20
- }), Y = i.struct("IncentivePoolInfo", {
20
+ }), Z = i.struct("IncentivePoolInfo", {
21
21
  /** Unique pool identifier */
22
- pool_id: F,
22
+ pool_id: R,
23
23
  /** Address holding the incentive funds */
24
- funds: F,
24
+ funds: R,
25
25
  /** Current phase of the incentive program */
26
26
  phase: i.u64(),
27
27
  /** Timestamp when the incentive started */
@@ -44,12 +44,12 @@ const F = i.bytes(32).transform({
44
44
  available: i.u256(),
45
45
  /** Total amount of incentives */
46
46
  total: i.u256()
47
- }), ge = i.struct("IncentivePoolInfoByPhase", {
47
+ }), ve = i.struct("IncentivePoolInfoByPhase", {
48
48
  /** Phase number */
49
49
  phase: i.u64(),
50
50
  /** List of incentive pools in this phase */
51
- pools: i.vector(Y)
52
- }), ye = i.struct("OracleInfo", {
51
+ pools: i.vector(Z)
52
+ }), je = i.struct("OracleInfo", {
53
53
  /** Oracle identifier */
54
54
  oracle_id: i.u8(),
55
55
  /** Current price as a 256-bit integer */
@@ -58,7 +58,7 @@ const F = i.bytes(32).transform({
58
58
  decimals: i.u8(),
59
59
  /** Whether the oracle data is valid */
60
60
  valid: i.bool()
61
- }), be = i.struct("FlashLoanAssetConfig", {
61
+ }), Ce = i.struct("FlashLoanAssetConfig", {
62
62
  /** Unique identifier for the flash loan asset */
63
63
  id: i.string(),
64
64
  /** Asset identifier */
@@ -75,7 +75,7 @@ const F = i.bytes(32).transform({
75
75
  max: i.u64(),
76
76
  /** Minimum flash loan amount */
77
77
  min: i.u64()
78
- }), we = i.struct("ReserveDataInfo", {
78
+ }), _e = i.struct("ReserveDataInfo", {
79
79
  /** Reserve identifier */
80
80
  id: i.u8(),
81
81
  /** Oracle identifier for price feeds */
@@ -122,123 +122,137 @@ const F = i.bytes(32).transform({
122
122
  liquidation_bonus: i.u256(),
123
123
  /** Liquidation threshold */
124
124
  liquidation_threshold: i.u256()
125
- }), Q = i.struct("UserStateInfo", {
125
+ }), x = i.struct("UserStateInfo", {
126
126
  /** Asset identifier */
127
127
  asset_id: i.u8(),
128
128
  /** User's current borrow balance */
129
129
  borrow_balance: i.u256(),
130
130
  /** User's current supply balance */
131
131
  supply_balance: i.u256()
132
- }), A = new q({
133
- url: z("mainnet")
132
+ }), ee = "1.3.1-dev.1", D = {
133
+ version: ee
134
+ }, te = D.version, re = () => {
135
+ if (typeof process != "undefined" && process.versions && process.versions.node)
136
+ try {
137
+ const e = require("os"), r = process.version, c = e.type(), t = e.arch();
138
+ return `Node.js ${r.startsWith("v") ? r.substring(1) : r}; ${c}/${t}`;
139
+ } catch {
140
+ return `Node.js ${process.version}; OS/Unknown (Error)`;
141
+ }
142
+ return "Node/Unknown";
143
+ }, ae = () => {
144
+ let e = "";
145
+ return typeof process != "undefined" && process.versions && process.versions.node && (e = `lending/${te} (${re()})`), e;
146
+ }, N = ae(), A = new J({
147
+ url: K("mainnet")
134
148
  });
135
- function E(e) {
136
- const a = [];
149
+ function L(e) {
150
+ const r = [];
137
151
  return e.forEach((c, t) => {
138
- const r = t === e.length - 1;
139
- if (typeof c == "object" && r) {
152
+ const a = t === e.length - 1;
153
+ if (typeof c == "object" && a) {
140
154
  const { client: n, disableCache: o, cacheTime: s, ...u } = c;
141
- a.push(u);
155
+ r.push(u);
142
156
  } else
143
- a.push(c);
144
- }), JSON.stringify(a);
157
+ r.push(c);
158
+ }), JSON.stringify(r);
145
159
  }
146
160
  function C(e) {
147
- const a = {};
161
+ const r = {};
148
162
  return (...c) => {
149
- const t = E(c);
150
- return a[t] || (a[t] = e(...c).finally(() => {
151
- a[t] = null;
152
- })), a[t];
163
+ const t = L(c);
164
+ return r[t] || (r[t] = e(...c).finally(() => {
165
+ r[t] = null;
166
+ })), r[t];
153
167
  };
154
168
  }
155
- function I(e) {
156
- let a = {};
169
+ function $(e) {
170
+ let r = {};
157
171
  return (...c) => {
158
- const t = c[c.length - 1], r = E(c), n = a[r];
159
- return !(t != null && t.disableCache) && typeof (n == null ? void 0 : n.data) != "undefined" && (typeof (t == null ? void 0 : t.cacheTime) == "undefined" || t.cacheTime > Date.now() - n.cacheAt) ? n.data : e(...c).then((o) => (a[r] = {
172
+ const t = c[c.length - 1], a = L(c), n = r[a];
173
+ return !(t != null && t.disableCache) && typeof (n == null ? void 0 : n.data) != "undefined" && (typeof (t == null ? void 0 : t.cacheTime) == "undefined" || t.cacheTime > Date.now() - n.cacheAt) ? n.data : e(...c).then((o) => (r[a] = {
160
174
  data: o,
161
175
  cacheAt: Date.now()
162
176
  }, o));
163
177
  };
164
178
  }
165
- function P(e) {
166
- return Array.isArray(e) ? e.map((a) => P(a)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
167
- (a, c) => ({
168
- ...a,
169
- [W(c)]: P(e[c])
179
+ function V(e) {
180
+ return Array.isArray(e) ? e.map((r) => V(r)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
181
+ (r, c) => ({
182
+ ...r,
183
+ [Y(c)]: V(e[c])
170
184
  }),
171
185
  {}
172
186
  ) : e;
173
187
  }
174
- function d(e, a) {
175
- return typeof e == "object" ? e : a(e);
188
+ function d(e, r) {
189
+ return typeof e == "object" ? e : r(e);
176
190
  }
177
- function X(e, a) {
178
- return typeof a == "string" ? e.object(a) : typeof a == "object" && a.$kind ? a : e.object(a.contract.pool);
191
+ function ce(e, r) {
192
+ return typeof r == "string" ? e.object(r) : typeof r == "object" && r.$kind ? r : e.object(r.contract.pool);
179
193
  }
180
- function B(e, a, c) {
194
+ function P(e, r, c) {
181
195
  if (e.results && e.results.length > 0) {
182
196
  if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
183
- return e.results[0].returnValues.map((t, r) => (a[r] || a[0]).parse(Uint8Array.from(t[0])));
197
+ return e.results[0].returnValues.map((t, a) => (r[a] || r[0]).parse(Uint8Array.from(t[0])));
184
198
  } else if (e.error)
185
199
  return console.log(`Get an error, msg: ${e.error}`), [];
186
200
  return [];
187
201
  }
188
- function f(e) {
189
- return J(e);
202
+ function m(e) {
203
+ return Q(e);
190
204
  }
191
- function D(e) {
192
- const a = (e || 0) / Math.pow(10, 27);
193
- return a > Math.pow(10, 5) ? 1 / 0 : a;
205
+ function M(e) {
206
+ const r = (e || 0) / Math.pow(10, 27);
207
+ return r > Math.pow(10, 5) ? 1 / 0 : r;
194
208
  }
195
- new N("https://hermes.pyth.network", {
209
+ new U("https://hermes.pyth.network", {
196
210
  timeout: 2e4
197
211
  });
198
- const Z = 27, R = (e, a) => {
199
- if (!Number(e) || !Number(a)) return new T(0);
200
- const c = new T(1).shiftedBy(1 * Z), t = c.multipliedBy(new T(0.5));
201
- return new T(e).multipliedBy(new T(a)).plus(t).dividedBy(c).integerValue(T.ROUND_DOWN);
202
- }, x = "1.3.0-dev.7", ee = {
203
- version: x
204
- }, b = I(
212
+ const ne = 27, E = (e, r) => {
213
+ if (!Number(e) || !Number(r)) return new T(0);
214
+ const c = new T(1).shiftedBy(1 * ne), t = c.multipliedBy(new T(0.5));
215
+ return new T(e).multipliedBy(new T(r)).plus(t).dividedBy(c).integerValue(T.ROUND_DOWN);
216
+ }, I = N ? {
217
+ "User-Agent": N
218
+ } : {}, b = $(
205
219
  C(async (e) => {
206
- const a = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&sdk=${ee.version}`;
207
- return (await fetch(a).then((t) => t.json())).data;
220
+ const r = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&sdk=${D.version}`;
221
+ return (await fetch(r, { headers: I }).then((t) => t.json())).data;
208
222
  })
209
223
  ), g = 1e3 * 60 * 5;
210
- var $ = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))($ || {});
211
- const V = I(
224
+ var k = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(k || {});
225
+ const S = $(
212
226
  C(async (e) => {
213
- const a = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
214
- return (await fetch(a).then((t) => t.json())).data;
227
+ const r = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
228
+ return (await fetch(r, { headers: I }).then((t) => t.json())).data;
215
229
  })
216
230
  );
217
- async function v(e, a) {
218
- const c = await V({
219
- ...a,
231
+ async function v(e, r) {
232
+ const c = await S({
233
+ ...r,
220
234
  cacheTime: g
221
235
  });
222
236
  if (typeof e == "object")
223
237
  return e;
224
- const t = c.find((r) => typeof e == "string" ? f(r.suiCoinType) === f(e) : typeof e == "number" ? r.id === e : !1);
238
+ const t = c.find((a) => typeof e == "string" ? m(a.suiCoinType) === m(e) : typeof e == "number" ? a.id === e : !1);
225
239
  if (!t)
226
240
  throw new Error("Pool not found");
227
241
  return t;
228
242
  }
229
- const he = I(
230
- C(async (e) => (await fetch("https://open-api.naviprotocol.io/api/navi/stats").then((t) => t.json())).data)
231
- ), ve = I(
243
+ const Te = $(
244
+ C(async (e) => (await fetch("https://open-api.naviprotocol.io/api/navi/stats", { headers: I }).then((t) => t.json())).data)
245
+ ), Ae = $(
232
246
  C(
233
- async (e) => await fetch("https://open-api.naviprotocol.io/api/navi/fee").then((t) => t.json())
247
+ async (e) => await fetch("https://open-api.naviprotocol.io/api/navi/fee", { headers: I }).then((t) => t.json())
234
248
  )
235
249
  );
236
- async function te(e, a, c, t) {
237
- const r = await b({
250
+ async function oe(e, r, c, t) {
251
+ const a = await b({
238
252
  ...t,
239
253
  cacheTime: g
240
- }), n = await v(a, t), o = typeof c == "object" && c.$kind === "GasCoin";
241
- if (f(n.suiCoinType) === f("0x2::sui::SUI") && o) {
254
+ }), n = await v(r, t), o = typeof c == "object" && c.$kind === "GasCoin";
255
+ if (m(n.suiCoinType) === m("0x2::sui::SUI") && o) {
242
256
  if (!(t != null && t.amount))
243
257
  throw new Error("Amount is required for sui coin");
244
258
  c = e.splitCoins(c, [t.amount]);
@@ -249,55 +263,55 @@ async function te(e, a, c, t) {
249
263
  arguments: [d(c, e.object)],
250
264
  typeArguments: [n.suiCoinType]
251
265
  }), t != null && t.accountCap ? e.moveCall({
252
- target: `${r.package}::incentive_v3::deposit_with_account_cap`,
266
+ target: `${a.package}::incentive_v3::deposit_with_account_cap`,
253
267
  arguments: [
254
268
  e.object("0x06"),
255
- e.object(r.storage),
269
+ e.object(a.storage),
256
270
  e.object(n.contract.pool),
257
271
  e.pure.u8(n.id),
258
272
  d(c, e.object),
259
- e.object(r.incentiveV2),
260
- e.object(r.incentiveV3),
273
+ e.object(a.incentiveV2),
274
+ e.object(a.incentiveV3),
261
275
  d(t.accountCap, e.object)
262
276
  ],
263
277
  typeArguments: [n.suiCoinType]
264
278
  }) : e.moveCall({
265
- target: `${r.package}::incentive_v3::entry_deposit`,
279
+ target: `${a.package}::incentive_v3::entry_deposit`,
266
280
  arguments: [
267
281
  e.object("0x06"),
268
- e.object(r.storage),
282
+ e.object(a.storage),
269
283
  e.object(n.contract.pool),
270
284
  e.pure.u8(n.id),
271
285
  d(c, e.object),
272
286
  s,
273
- e.object(r.incentiveV2),
274
- e.object(r.incentiveV3)
287
+ e.object(a.incentiveV2),
288
+ e.object(a.incentiveV3)
275
289
  ],
276
290
  typeArguments: [n.suiCoinType]
277
- }), r.version === 2 && n.id === 0 && e.moveCall({
278
- target: `${r.package}::pool::refresh_stake`,
291
+ }), a.version === 2 && n.id === 0 && e.moveCall({
292
+ target: `${a.package}::pool::refresh_stake`,
279
293
  arguments: [e.object(n.contract.pool), e.object("0x05")]
280
294
  }), e;
281
295
  }
282
- async function je(e, a, c, t) {
283
- const r = await b({
296
+ async function Ie(e, r, c, t) {
297
+ const a = await b({
284
298
  ...t,
285
299
  cacheTime: g
286
- }), n = await v(a, t), o = d(c, e.pure.u64);
300
+ }), n = await v(r, t), o = d(c, e.pure.u64);
287
301
  let s;
288
- if (r.version === 1)
302
+ if (a.version === 1)
289
303
  if (t != null && t.accountCap) {
290
304
  const [l] = e.moveCall({
291
- target: `${r.package}::incentive_v3::withdraw_with_account_cap`,
305
+ target: `${a.package}::incentive_v3::withdraw_with_account_cap`,
292
306
  arguments: [
293
307
  e.object("0x06"),
294
- e.object(r.priceOracle),
295
- e.object(r.storage),
308
+ e.object(a.priceOracle),
309
+ e.object(a.storage),
296
310
  e.object(n.contract.pool),
297
311
  e.pure.u8(n.id),
298
312
  o,
299
- e.object(r.incentiveV2),
300
- e.object(r.incentiveV3),
313
+ e.object(a.incentiveV2),
314
+ e.object(a.incentiveV3),
301
315
  d(t.accountCap, e.object)
302
316
  ],
303
317
  typeArguments: [n.suiCoinType]
@@ -305,16 +319,16 @@ async function je(e, a, c, t) {
305
319
  s = l;
306
320
  } else {
307
321
  const [l] = e.moveCall({
308
- target: `${r.package}::incentive_v3::withdraw`,
322
+ target: `${a.package}::incentive_v3::withdraw`,
309
323
  arguments: [
310
324
  e.object("0x06"),
311
- e.object(r.priceOracle),
312
- e.object(r.storage),
325
+ e.object(a.priceOracle),
326
+ e.object(a.storage),
313
327
  e.object(n.contract.pool),
314
328
  e.pure.u8(n.id),
315
329
  o,
316
- e.object(r.incentiveV2),
317
- e.object(r.incentiveV3)
330
+ e.object(a.incentiveV2),
331
+ e.object(a.incentiveV3)
318
332
  ],
319
333
  typeArguments: [n.suiCoinType]
320
334
  });
@@ -322,16 +336,16 @@ async function je(e, a, c, t) {
322
336
  }
323
337
  else if (t != null && t.accountCap) {
324
338
  const [l] = e.moveCall({
325
- target: `${r.package}::incentive_v3::withdraw_with_account_cap_v2`,
339
+ target: `${a.package}::incentive_v3::withdraw_with_account_cap_v2`,
326
340
  arguments: [
327
341
  e.object("0x06"),
328
- e.object(r.priceOracle),
329
- e.object(r.storage),
342
+ e.object(a.priceOracle),
343
+ e.object(a.storage),
330
344
  e.object(n.contract.pool),
331
345
  e.pure.u8(n.id),
332
346
  o,
333
- e.object(r.incentiveV2),
334
- e.object(r.incentiveV3),
347
+ e.object(a.incentiveV2),
348
+ e.object(a.incentiveV3),
335
349
  d(t.accountCap, e.object),
336
350
  e.object("0x05")
337
351
  ],
@@ -340,16 +354,16 @@ async function je(e, a, c, t) {
340
354
  s = l;
341
355
  } else {
342
356
  const [l] = e.moveCall({
343
- target: `${r.package}::incentive_v3::withdraw_v2`,
357
+ target: `${a.package}::incentive_v3::withdraw_v2`,
344
358
  arguments: [
345
359
  e.object("0x06"),
346
- e.object(r.priceOracle),
347
- e.object(r.storage),
360
+ e.object(a.priceOracle),
361
+ e.object(a.storage),
348
362
  e.object(n.contract.pool),
349
363
  e.pure.u8(n.id),
350
364
  o,
351
- e.object(r.incentiveV2),
352
- e.object(r.incentiveV3),
365
+ e.object(a.incentiveV2),
366
+ e.object(a.incentiveV3),
353
367
  e.object("0x05")
354
368
  ],
355
369
  typeArguments: [n.suiCoinType]
@@ -362,25 +376,25 @@ async function je(e, a, c, t) {
362
376
  typeArguments: [n.suiCoinType]
363
377
  });
364
378
  }
365
- async function Ce(e, a, c, t) {
366
- const r = await b({
379
+ async function $e(e, r, c, t) {
380
+ const a = await b({
367
381
  ...t,
368
382
  cacheTime: g
369
- }), n = await v(a, t), o = d(c, e.pure.u64);
383
+ }), n = await v(r, t), o = d(c, e.pure.u64);
370
384
  let s;
371
- if (r.version === 1)
385
+ if (a.version === 1)
372
386
  if (t != null && t.accountCap) {
373
387
  const [l] = e.moveCall({
374
- target: `${r.package}::incentive_v3::borrow_with_account_cap`,
388
+ target: `${a.package}::incentive_v3::borrow_with_account_cap`,
375
389
  arguments: [
376
390
  e.object("0x06"),
377
- e.object(r.priceOracle),
378
- e.object(r.storage),
391
+ e.object(a.priceOracle),
392
+ e.object(a.storage),
379
393
  e.object(n.contract.pool),
380
394
  e.pure.u8(n.id),
381
395
  o,
382
- e.object(r.incentiveV2),
383
- e.object(r.incentiveV3),
396
+ e.object(a.incentiveV2),
397
+ e.object(a.incentiveV3),
384
398
  d(t.accountCap, e.object)
385
399
  ],
386
400
  typeArguments: [n.suiCoinType]
@@ -388,16 +402,16 @@ async function Ce(e, a, c, t) {
388
402
  s = l;
389
403
  } else {
390
404
  const [l] = e.moveCall({
391
- target: `${r.package}::incentive_v3::borrow`,
405
+ target: `${a.package}::incentive_v3::borrow`,
392
406
  arguments: [
393
407
  e.object("0x06"),
394
- e.object(r.priceOracle),
395
- e.object(r.storage),
408
+ e.object(a.priceOracle),
409
+ e.object(a.storage),
396
410
  e.object(n.contract.pool),
397
411
  e.pure.u8(n.id),
398
412
  o,
399
- e.object(r.incentiveV2),
400
- e.object(r.incentiveV3)
413
+ e.object(a.incentiveV2),
414
+ e.object(a.incentiveV3)
401
415
  ],
402
416
  typeArguments: [n.suiCoinType]
403
417
  });
@@ -405,16 +419,16 @@ async function Ce(e, a, c, t) {
405
419
  }
406
420
  else if (t != null && t.accountCap) {
407
421
  const [l] = e.moveCall({
408
- target: `${r.package}::incentive_v3::borrow_with_account_cap_v2`,
422
+ target: `${a.package}::incentive_v3::borrow_with_account_cap_v2`,
409
423
  arguments: [
410
424
  e.object("0x06"),
411
- e.object(r.priceOracle),
412
- e.object(r.storage),
425
+ e.object(a.priceOracle),
426
+ e.object(a.storage),
413
427
  e.object(n.contract.pool),
414
428
  e.pure.u8(n.id),
415
429
  o,
416
- e.object(r.incentiveV2),
417
- e.object(r.incentiveV3),
430
+ e.object(a.incentiveV2),
431
+ e.object(a.incentiveV3),
418
432
  d(t.accountCap, e.object),
419
433
  e.object("0x05")
420
434
  ],
@@ -423,16 +437,16 @@ async function Ce(e, a, c, t) {
423
437
  s = l;
424
438
  } else {
425
439
  const [l] = e.moveCall({
426
- target: `${r.package}::incentive_v3::borrow_v2`,
440
+ target: `${a.package}::incentive_v3::borrow_v2`,
427
441
  arguments: [
428
442
  e.object("0x06"),
429
- e.object(r.priceOracle),
430
- e.object(r.storage),
443
+ e.object(a.priceOracle),
444
+ e.object(a.storage),
431
445
  e.object(n.contract.pool),
432
446
  e.pure.u8(n.id),
433
447
  o,
434
- e.object(r.incentiveV2),
435
- e.object(r.incentiveV3),
448
+ e.object(a.incentiveV2),
449
+ e.object(a.incentiveV3),
436
450
  e.object("0x05")
437
451
  ],
438
452
  typeArguments: [n.suiCoinType]
@@ -445,12 +459,12 @@ async function Ce(e, a, c, t) {
445
459
  typeArguments: [n.suiCoinType]
446
460
  });
447
461
  }
448
- async function _e(e, a, c, t) {
449
- const r = await b({
462
+ async function ke(e, r, c, t) {
463
+ const a = await b({
450
464
  ...t,
451
465
  cacheTime: g
452
- }), n = await v(a, t), o = typeof c == "object" && c.$kind === "GasCoin";
453
- if (f(n.suiCoinType) === f("0x2::sui::SUI") && o) {
466
+ }), n = await v(r, t), o = typeof c == "object" && c.$kind === "GasCoin";
467
+ if (m(n.suiCoinType) === m("0x2::sui::SUI") && o) {
454
468
  if (!(t != null && t.amount))
455
469
  throw new Error("Amount is required for sui coin");
456
470
  c = e.splitCoins(c, [t.amount]);
@@ -461,50 +475,50 @@ async function _e(e, a, c, t) {
461
475
  arguments: [d(c, e.object)],
462
476
  typeArguments: [n.suiCoinType]
463
477
  }), t != null && t.accountCap ? e.moveCall({
464
- target: `${r.package}::incentive_v3::repay_with_account_cap`,
478
+ target: `${a.package}::incentive_v3::repay_with_account_cap`,
465
479
  arguments: [
466
480
  e.object("0x06"),
467
- e.object(r.priceOracle),
468
- e.object(r.storage),
481
+ e.object(a.priceOracle),
482
+ e.object(a.storage),
469
483
  e.object(n.contract.pool),
470
484
  e.pure.u8(n.id),
471
485
  d(c, e.object),
472
486
  s,
473
- e.object(r.incentiveV2),
474
- e.object(r.incentiveV3),
487
+ e.object(a.incentiveV2),
488
+ e.object(a.incentiveV3),
475
489
  d(t.accountCap, e.object)
476
490
  ],
477
491
  typeArguments: [n.suiCoinType]
478
492
  }) : e.moveCall({
479
- target: `${r.package}::incentive_v3::entry_repay`,
493
+ target: `${a.package}::incentive_v3::entry_repay`,
480
494
  arguments: [
481
495
  e.object("0x06"),
482
- e.object(r.priceOracle),
483
- e.object(r.storage),
496
+ e.object(a.priceOracle),
497
+ e.object(a.storage),
484
498
  e.object(n.contract.pool),
485
499
  e.pure.u8(n.id),
486
500
  d(c, e.object),
487
501
  s,
488
- e.object(r.incentiveV2),
489
- e.object(r.incentiveV3)
502
+ e.object(a.incentiveV2),
503
+ e.object(a.incentiveV3)
490
504
  ],
491
505
  typeArguments: [n.suiCoinType]
492
506
  }), e;
493
507
  }
494
- const Te = I(
508
+ const Be = $(
495
509
  C(
496
510
  async (e) => {
497
- var r;
498
- const a = await b({
511
+ var a;
512
+ const r = await b({
499
513
  ...e
500
514
  });
501
515
  if (e != null && e.address && typeof (e == null ? void 0 : e.asset) != "undefined")
502
516
  try {
503
- const n = await v(e.asset, e), o = (r = e == null ? void 0 : e.client) != null ? r : A, s = new k();
517
+ const n = await v(e.asset, e), o = (a = e == null ? void 0 : e.client) != null ? a : A, s = new B();
504
518
  s.moveCall({
505
- target: `${a.package}::incentive_v3::get_borrow_fee_v2`,
519
+ target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
506
520
  arguments: [
507
- s.object(a.incentiveV3),
521
+ s.object(r.incentiveV3),
508
522
  s.pure.address(e.address),
509
523
  s.pure.u8(n.id),
510
524
  s.pure.u64(1e4)
@@ -514,42 +528,42 @@ const Te = I(
514
528
  const u = await o.devInspectTransactionBlock({
515
529
  transactionBlock: s,
516
530
  sender: e.address
517
- }), l = B(u, [h.u64()]);
531
+ }), l = P(u, [h.u64()]);
518
532
  return (Number(l[0]) || 0) / 100;
519
533
  } catch (n) {
520
534
  console.error(n);
521
535
  }
522
536
  const t = (await A.getObject({
523
- id: a.incentiveV3,
537
+ id: r.incentiveV3,
524
538
  options: { showType: !0, showOwner: !0, showContent: !0 }
525
539
  })).data.content.fields.borrow_fee_rate;
526
540
  return Number(t) / 100;
527
541
  }
528
542
  )
529
543
  );
530
- function Ae(e, a, c) {
531
- const t = typeof (c == null ? void 0 : c.balance) == "number", r = t ? c.balance : 0;
544
+ function Pe(e, r, c) {
545
+ const t = typeof (c == null ? void 0 : c.balance) == "number", a = t ? c.balance : 0;
532
546
  let n = 0;
533
547
  const o = [];
534
548
  let s = "";
535
- if (a.sort((l, p) => Number(p.balance) - Number(l.balance)).forEach((l) => {
536
- if (!(t && n >= r) && Number(l.balance) !== 0) {
549
+ if (r.sort((l, p) => Number(p.balance) - Number(l.balance)).forEach((l) => {
550
+ if (!(t && n >= a) && Number(l.balance) !== 0) {
537
551
  if (s || (s = l.coinType), s !== l.coinType)
538
552
  throw new Error("All coins must be of the same type");
539
553
  n += Number(l.balance), o.push(l.coinObjectId);
540
554
  }
541
555
  }), o.length === 0)
542
556
  throw new Error("No coins to merge");
543
- if (t && n < r)
557
+ if (t && n < a)
544
558
  throw new Error(
545
- `Balance is less than the specified balance: ${n} < ${r}`
559
+ `Balance is less than the specified balance: ${n} < ${a}`
546
560
  );
547
- if (f(s) === f("0x2::sui::SUI") && (c != null && c.useGasCoin))
548
- return t ? e.splitCoins(e.gas, [e.pure.u64(r)]) : e.gas;
561
+ if (m(s) === m("0x2::sui::SUI") && (c != null && c.useGasCoin))
562
+ return t ? e.splitCoins(e.gas, [e.pure.u64(a)]) : e.gas;
549
563
  const u = o.length === 1 ? e.object(o[0]) : e.mergeCoins(o[0], o.slice(1));
550
- return t ? e.splitCoins(u, [e.pure.u64(r)]) : u;
564
+ return t ? e.splitCoins(u, [e.pure.u64(a)]) : u;
551
565
  }
552
- async function L(e, a, c, t, r, n, o) {
566
+ async function O(e, r, c, t, a, n, o) {
553
567
  const s = await b({
554
568
  ...o,
555
569
  cacheTime: g
@@ -560,74 +574,74 @@ async function L(e, a, c, t, r, n, o) {
560
574
  e.object("0x06"),
561
575
  e.object(s.storage),
562
576
  e.object(s.oracle.priceOracle),
563
- X(e, u),
564
- d(a, e.pure.address),
577
+ ce(e, u),
578
+ d(r, e.pure.address),
565
579
  d(u.id, e.pure.u8),
566
580
  d(t, e.pure.u64),
567
- d(r, e.pure.u64),
581
+ d(a, e.pure.u64),
568
582
  d(n, e.pure.bool)
569
583
  ],
570
584
  typeArguments: [u.suiCoinType]
571
585
  });
572
586
  }
573
- async function ae(e, a, c) {
574
- return L(e, a, 0, 0, 0, !1, c);
587
+ async function se(e, r, c) {
588
+ return O(e, r, 0, 0, 0, !1, c);
575
589
  }
576
- const Ie = I(
577
- async (e, a) => {
590
+ const Ve = $(
591
+ async (e, r) => {
578
592
  var l;
579
593
  const c = await b({
580
- ...a,
594
+ ...r,
581
595
  cacheTime: g
582
- }), t = new k(), r = (l = a == null ? void 0 : a.client) != null ? l : A, n = await V(a);
596
+ }), t = new B(), a = (l = r == null ? void 0 : r.client) != null ? l : A, n = await S(r);
583
597
  t.moveCall({
584
598
  target: `${c.uiGetter}::getter_unchecked::get_user_state`,
585
599
  arguments: [t.object(c.storage), t.pure.address(e)]
586
600
  });
587
- const o = await r.devInspectTransactionBlock({
601
+ const o = await a.devInspectTransactionBlock({
588
602
  transactionBlock: t,
589
603
  sender: e
590
- }), s = B(o, [h.vector(Q)]);
591
- return P(
604
+ }), s = P(o, [h.vector(x)]);
605
+ return V(
592
606
  s[0].filter((p) => p.supply_balance !== "0" || p.borrow_balance !== "0")
593
607
  ).map((p) => {
594
- const w = n.find((j) => j.id === p.assetId), m = R(
608
+ const w = n.find((j) => j.id === p.assetId), f = E(
595
609
  p.supplyBalance,
596
610
  w.currentSupplyIndex
597
- ).toString(), y = R(
611
+ ).toString(), y = E(
598
612
  p.borrowBalance,
599
613
  w.currentBorrowIndex
600
614
  ).toString();
601
615
  return {
602
616
  ...p,
603
- supplyBalance: m,
617
+ supplyBalance: f,
604
618
  borrowBalance: y,
605
619
  pool: w
606
620
  };
607
621
  }).filter((p) => !!p.pool);
608
622
  }
609
623
  );
610
- async function $e(e, a) {
624
+ async function Se(e, r) {
611
625
  var o;
612
- const c = (o = a == null ? void 0 : a.client) != null ? o : A, t = new k();
613
- await ae(t, e, a);
614
- const r = await c.devInspectTransactionBlock({
626
+ const c = (o = r == null ? void 0 : r.client) != null ? o : A, t = new B();
627
+ await se(t, e, r);
628
+ const a = await c.devInspectTransactionBlock({
615
629
  transactionBlock: t,
616
630
  sender: e
617
- }), n = B(r, [h.u256()]);
618
- return D(Number(n[0]) || 0);
631
+ }), n = P(a, [h.u256()]);
632
+ return M(Number(n[0]) || 0);
619
633
  }
620
- async function ke(e, a, c, t) {
621
- var m;
622
- const r = (m = t == null ? void 0 : t.client) != null ? m : A, n = new k();
634
+ async function Fe(e, r, c, t) {
635
+ var f;
636
+ const a = (f = t == null ? void 0 : t.client) != null ? f : A, n = new B();
623
637
  let o = 0, s = 0;
624
- const u = await v(a, t);
638
+ const u = await v(r, t);
625
639
  if (c.forEach((y) => {
626
- y.type === $.Supply ? o += y.amount : y.type === $.Withdraw ? o -= y.amount : y.type === $.Borrow ? s += y.amount : y.type === $.Repay && (s -= y.amount);
640
+ y.type === k.Supply ? o += y.amount : y.type === k.Withdraw ? o -= y.amount : y.type === k.Borrow ? s += y.amount : y.type === k.Repay && (s -= y.amount);
627
641
  }), o * s < 0)
628
642
  throw new Error("Invalid operations");
629
643
  const l = o > 0 || s > 0;
630
- await L(
644
+ await O(
631
645
  n,
632
646
  e,
633
647
  u,
@@ -636,32 +650,32 @@ async function ke(e, a, c, t) {
636
650
  l,
637
651
  t
638
652
  );
639
- const p = await r.devInspectTransactionBlock({
653
+ const p = await a.devInspectTransactionBlock({
640
654
  transactionBlock: n,
641
655
  sender: e
642
- }), w = B(p, [h.u256()]);
643
- return D(Number(w[0]) || 0);
656
+ }), w = P(p, [h.u256()]);
657
+ return M(Number(w[0]) || 0);
644
658
  }
645
- const Be = C(
646
- async (e, a) => {
659
+ const Re = C(
660
+ async (e, r) => {
647
661
  const c = new URLSearchParams();
648
- a != null && a.cursor && c.set("cursor", a.cursor), c.set("userAddress", e);
662
+ r != null && r.cursor && c.set("cursor", r.cursor), c.set("userAddress", e);
649
663
  const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${c.toString()}`;
650
- return (await fetch(t).then((n) => n.json())).data;
664
+ return (await fetch(t, { headers: I }).then((n) => n.json())).data;
651
665
  }
652
666
  );
653
- async function Pe(e, a) {
667
+ async function Ne(e, r) {
654
668
  var n;
655
669
  let c = null;
656
- const t = [], r = (n = a == null ? void 0 : a.client) != null ? n : A;
670
+ const t = [], a = (n = r == null ? void 0 : r.client) != null ? n : A;
657
671
  do {
658
672
  let o;
659
- if (a != null && a.coinType ? o = await r.getCoins({
673
+ if (r != null && r.coinType ? o = await a.getCoins({
660
674
  owner: e,
661
- coinType: a == null ? void 0 : a.coinType,
675
+ coinType: r == null ? void 0 : r.coinType,
662
676
  cursor: c,
663
677
  limit: 100
664
- }) : o = await r.getAllCoins({
678
+ }) : o = await a.getAllCoins({
665
679
  owner: e,
666
680
  cursor: c,
667
681
  limit: 100
@@ -671,62 +685,62 @@ async function Pe(e, a) {
671
685
  } while (c);
672
686
  return t;
673
687
  }
674
- const M = new N("https://hermes.pyth.network", {
688
+ const q = new U("https://hermes.pyth.network", {
675
689
  timeout: 1e4
676
690
  });
677
- async function re(e) {
691
+ async function ie(e) {
678
692
  try {
679
- const a = [], c = await M.getLatestPriceFeeds(e);
680
- if (!c) return a;
693
+ const r = [], c = await q.getLatestPriceFeeds(e);
694
+ if (!c) return r;
681
695
  const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
682
- for (const r of c) {
683
- const n = r.getPriceUnchecked();
696
+ for (const a of c) {
697
+ const n = a.getPriceUnchecked();
684
698
  if (n.publishTime > t) {
685
699
  console.warn(
686
- `pyth price feed is invalid, id: ${r.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
700
+ `pyth price feed is invalid, id: ${a.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
687
701
  );
688
702
  continue;
689
703
  }
690
- t - r.getPriceUnchecked().publishTime > 30 && (console.info(
691
- `stale price feed, id: ${r.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
692
- ), a.push(r.id));
704
+ t - a.getPriceUnchecked().publishTime > 30 && (console.info(
705
+ `stale price feed, id: ${a.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
706
+ ), r.push(a.id));
693
707
  }
694
- return a;
695
- } catch (a) {
696
- throw new Error(`failed to get pyth stale price feed id, msg: ${a.message}`);
708
+ return r;
709
+ } catch (r) {
710
+ throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
697
711
  }
698
712
  }
699
- async function ce(e, a, c) {
713
+ async function ue(e, r, c) {
700
714
  var n;
701
- const t = (n = c == null ? void 0 : c.client) != null ? n : A, r = await b({
715
+ const t = (n = c == null ? void 0 : c.client) != null ? n : A, a = await b({
702
716
  ...c,
703
717
  cacheTime: g
704
718
  });
705
719
  try {
706
- const o = await M.getPriceFeedsUpdateData(a);
707
- return await new K(
720
+ const o = await q.getPriceFeedsUpdateData(r);
721
+ return await new X(
708
722
  t,
709
- r.oracle.pythStateId,
710
- r.oracle.wormholeStateId
711
- ).updatePriceFeeds(e, o, a);
723
+ a.oracle.pythStateId,
724
+ a.oracle.wormholeStateId
725
+ ).updatePriceFeeds(e, o, r);
712
726
  } catch (o) {
713
727
  throw new Error(`failed to update pyth price feeds, msg: ${o.message}`);
714
728
  }
715
729
  }
716
- async function Ve(e, a, c) {
730
+ async function Ee(e, r, c) {
717
731
  const t = await b({
718
732
  ...c,
719
733
  cacheTime: g
720
734
  });
721
735
  if (c != null && c.updatePythPriceFeeds) {
722
- const r = a.filter((n) => !!n.pythPriceFeedId).map((n) => n.pythPriceFeedId);
736
+ const a = r.filter((n) => !!n.pythPriceFeedId).map((n) => n.pythPriceFeedId);
723
737
  try {
724
- const n = await re(r);
725
- n.length > 0 && await ce(e, n, c);
738
+ const n = await ie(a);
739
+ n.length > 0 && await ue(e, n, c);
726
740
  } catch {
727
741
  }
728
742
  }
729
- for (const r of a)
743
+ for (const a of r)
730
744
  e.moveCall({
731
745
  target: `${t.oracle.packageId}::oracle_pro::update_single_price`,
732
746
  arguments: [
@@ -738,52 +752,52 @@ async function Ve(e, a, c) {
738
752
  // Price oracle contract
739
753
  e.object(t.oracle.supraOracleHolder),
740
754
  // Supra oracle holder
741
- e.object(r.pythPriceInfoObject),
755
+ e.object(a.pythPriceInfoObject),
742
756
  // Pyth price info object
743
- e.pure.address(r.feedId)
757
+ e.pure.address(a.feedId)
744
758
  // Price feed ID
745
759
  ]
746
760
  });
747
761
  return e;
748
762
  }
749
- async function ne(e) {
763
+ async function le(e) {
750
764
  return (await b({
751
765
  ...e,
752
766
  cacheTime: g
753
767
  })).oracle.feeds;
754
768
  }
755
- function Se(e, a) {
756
- return e.filter((c) => !!(a != null && a.lendingState && a.lendingState.find((r) => r.assetId === c.assetId) || a != null && a.pools && a.pools.find((r) => r.id === c.assetId)));
769
+ function Ue(e, r) {
770
+ return e.filter((c) => !!(r != null && r.lendingState && r.lendingState.find((a) => a.assetId === c.assetId) || r != null && r.pools && r.pools.find((a) => a.id === c.assetId)));
757
771
  }
758
- const S = I(
772
+ const F = $(
759
773
  C(async (e) => {
760
- const a = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`, c = await fetch(a).then((t) => t.json());
774
+ const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`, c = await fetch(r, { headers: I }).then((t) => t.json());
761
775
  return Object.keys(c.data).map((t) => ({
762
776
  ...c.data[t],
763
777
  coinType: t
764
778
  }));
765
779
  })
766
780
  );
767
- async function Fe(e, a) {
768
- return (await S(a)).find((t) => typeof e == "string" ? f(t.coinType) === f(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
781
+ async function De(e, r) {
782
+ return (await F(r)).find((t) => typeof e == "string" ? m(t.coinType) === m(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
769
783
  }
770
- async function Re(e, a, c, t) {
771
- const r = await b({
784
+ async function Le(e, r, c, t) {
785
+ const a = await b({
772
786
  ...t,
773
787
  cacheTime: g
774
- }), n = await v(a, t);
775
- if (!(await S({
788
+ }), n = await v(r, t);
789
+ if (!(await F({
776
790
  ...t,
777
791
  cacheTime: g
778
792
  })).some(
779
- (u) => f(u.coinType) === f(n.suiCoinType)
793
+ (u) => m(u.coinType) === m(n.suiCoinType)
780
794
  ))
781
795
  throw new Error("Pool does not support flashloan");
782
- if (r.version === 1) {
796
+ if (a.version === 1) {
783
797
  const [u, l] = e.moveCall({
784
- target: `${r.package}::lending::flash_loan_with_ctx`,
798
+ target: `${a.package}::lending::flash_loan_with_ctx`,
785
799
  arguments: [
786
- e.object(r.flashloanConfig),
800
+ e.object(a.flashloanConfig),
787
801
  e.object(n.contract.pool),
788
802
  d(c, e.pure.u64)
789
803
  ],
@@ -792,9 +806,9 @@ async function Re(e, a, c, t) {
792
806
  return [u, l];
793
807
  } else {
794
808
  const [u, l] = e.moveCall({
795
- target: `${r.package}::lending::flash_loan_with_ctx_v2`,
809
+ target: `${a.package}::lending::flash_loan_with_ctx_v2`,
796
810
  arguments: [
797
- e.object(r.flashloanConfig),
811
+ e.object(a.flashloanConfig),
798
812
  e.object(n.contract.pool),
799
813
  d(c, e.pure.u64),
800
814
  e.object("0x05")
@@ -804,16 +818,16 @@ async function Re(e, a, c, t) {
804
818
  return [u, l];
805
819
  }
806
820
  }
807
- async function Ne(e, a, c, t, r) {
821
+ async function Me(e, r, c, t, a) {
808
822
  const n = await b({
809
- ...r,
823
+ ...a,
810
824
  cacheTime: g
811
- }), o = await v(a, r);
812
- if (!(await S({
813
- ...r,
825
+ }), o = await v(r, a);
826
+ if (!(await F({
827
+ ...a,
814
828
  cacheTime: g
815
829
  })).some(
816
- (p) => f(p.coinType) === f(o.suiCoinType)
830
+ (p) => m(p.coinType) === m(o.suiCoinType)
817
831
  ))
818
832
  throw new Error("Pool does not support flashloan");
819
833
  const [l] = e.moveCall({
@@ -829,11 +843,11 @@ async function Ne(e, a, c, t, r) {
829
843
  });
830
844
  return [l];
831
845
  }
832
- async function Ee(e, a, c, t, r, n) {
846
+ async function Oe(e, r, c, t, a, n) {
833
847
  const o = {
834
848
  ...n,
835
849
  cacheTime: g
836
- }, s = await b(o), u = await v(a, o), l = await v(t, o);
850
+ }, s = await b(o), u = await v(r, o), l = await v(t, o);
837
851
  if (s.version === 1) {
838
852
  const [p, w] = e.moveCall({
839
853
  target: `${s.package}::incentive_v3::liquidation`,
@@ -854,7 +868,7 @@ async function Ee(e, a, c, t, r, n) {
854
868
  // Collateral asset ID
855
869
  e.object(l.contract.pool),
856
870
  // Collateral asset pool contract
857
- d(r, e.pure.address),
871
+ d(a, e.pure.address),
858
872
  // Borrower address
859
873
  e.object(s.incentiveV2),
860
874
  // Incentive V2 contract
@@ -884,7 +898,7 @@ async function Ee(e, a, c, t, r, n) {
884
898
  // Collateral asset ID
885
899
  e.object(l.contract.pool),
886
900
  // Collateral asset pool contract
887
- d(r, e.pure.address),
901
+ d(a, e.pure.address),
888
902
  // Borrower address
889
903
  e.object(s.incentiveV2),
890
904
  // Incentive V2 contract
@@ -898,15 +912,15 @@ async function Ee(e, a, c, t, r, n) {
898
912
  return [p, w];
899
913
  }
900
914
  }
901
- async function De(e, a) {
915
+ async function qe(e, r) {
902
916
  var p;
903
- const c = await ne(a), t = await V({
904
- ...a,
917
+ const c = await le(r), t = await S({
918
+ ...r,
905
919
  cacheTime: g
906
- }), r = (p = a == null ? void 0 : a.client) != null ? p : A, n = await b({
907
- ...a,
920
+ }), a = (p = r == null ? void 0 : r.client) != null ? p : A, n = await b({
921
+ ...r,
908
922
  cacheTime: g
909
- }), o = new k();
923
+ }), o = new B();
910
924
  o.moveCall({
911
925
  target: `${n.uiGetter}::incentive_v3_getter::get_user_atomic_claimable_rewards`,
912
926
  arguments: [
@@ -920,10 +934,10 @@ async function De(e, a) {
920
934
  // User address
921
935
  ]
922
936
  });
923
- const s = await r.devInspectTransactionBlock({
937
+ const s = await a.devInspectTransactionBlock({
924
938
  transactionBlock: o,
925
939
  sender: e
926
- }), u = B(
940
+ }), u = P(
927
941
  s,
928
942
  [
929
943
  h.vector(h.string()),
@@ -940,89 +954,89 @@ async function De(e, a) {
940
954
  ), l = [];
941
955
  if (u.length === 5 && Array.isArray(u[0])) {
942
956
  const w = u[0].length;
943
- for (let m = 0; m < w; m++) {
957
+ for (let f = 0; f < w; f++) {
944
958
  const y = c.find(
945
- (_) => f(_.coinType) === f(u[1][m])
959
+ (_) => m(_.coinType) === m(u[1][f])
946
960
  ), j = t.find(
947
- (_) => f(_.coinType) === f(u[0][m])
961
+ (_) => m(_.coinType) === m(u[0][f])
948
962
  );
949
963
  !y || !j || l.push({
950
964
  assetId: j.id,
951
- assetCoinType: f(u[0][m]),
952
- rewardCoinType: f(u[1][m]),
953
- option: Number(u[2][m]),
954
- userClaimableReward: Number(u[4][m]) / Math.pow(10, y.priceDecimal),
955
- ruleIds: Array.isArray(u[3][m]) ? u[3][m] : [u[3][m]]
965
+ assetCoinType: m(u[0][f]),
966
+ rewardCoinType: m(u[1][f]),
967
+ option: Number(u[2][f]),
968
+ userClaimableReward: Number(u[4][f]) / Math.pow(10, y.priceDecimal),
969
+ ruleIds: Array.isArray(u[3][f]) ? u[3][f] : [u[3][f]]
956
970
  });
957
971
  }
958
972
  }
959
973
  return l;
960
974
  }
961
- function Le(e) {
962
- const a = /* @__PURE__ */ new Map();
975
+ function He(e) {
976
+ const r = /* @__PURE__ */ new Map();
963
977
  e.forEach((t) => {
964
- const r = t.assetId, n = t.option, o = `${r}-${n}-${t.rewardCoinType}`;
965
- a.has(o) ? a.get(o).total += t.userClaimableReward : a.set(o, {
966
- assetId: r,
978
+ const a = t.assetId, n = t.option, o = `${a}-${n}-${t.rewardCoinType}`;
979
+ r.has(o) ? r.get(o).total += t.userClaimableReward : r.set(o, {
980
+ assetId: a,
967
981
  rewardType: n,
968
982
  coinType: t.rewardCoinType,
969
983
  total: Number(t.userClaimableReward)
970
984
  });
971
985
  });
972
986
  const c = /* @__PURE__ */ new Map();
973
- for (const { assetId: t, rewardType: r, coinType: n, total: o } of a.values()) {
974
- const s = `${t}-${r}`;
975
- c.has(s) || c.set(s, { assetId: t, rewardType: r, rewards: /* @__PURE__ */ new Map() });
987
+ for (const { assetId: t, rewardType: a, coinType: n, total: o } of r.values()) {
988
+ const s = `${t}-${a}`;
989
+ c.has(s) || c.set(s, { assetId: t, rewardType: a, rewards: /* @__PURE__ */ new Map() });
976
990
  const u = c.get(s);
977
991
  u.rewards.set(n, (u.rewards.get(n) || 0) + o);
978
992
  }
979
993
  return Array.from(c.values()).map((t) => ({
980
994
  assetId: t.assetId,
981
995
  rewardType: t.rewardType,
982
- rewards: Array.from(t.rewards.entries()).map(([r, n]) => ({
983
- coinType: r,
996
+ rewards: Array.from(t.rewards.entries()).map(([a, n]) => ({
997
+ coinType: a,
984
998
  available: n.toFixed(6)
985
999
  }))
986
1000
  }));
987
1001
  }
988
- const Me = C(
1002
+ const Ge = C(
989
1003
  async (e) => {
990
- const a = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}`;
991
- return (await fetch(a).then((t) => t.json())).data;
1004
+ const r = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}`;
1005
+ return (await fetch(r, { headers: I }).then((t) => t.json())).data;
992
1006
  }
993
- ), Ue = C(
994
- async (e, a) => {
995
- const c = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${(a == null ? void 0 : a.page) || 1}&pageSize=${(a == null ? void 0 : a.size) || 400}`, t = await fetch(c).then((r) => r.json());
996
- return P({
1007
+ ), ze = C(
1008
+ async (e, r) => {
1009
+ const c = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${(r == null ? void 0 : r.page) || 1}&pageSize=${(r == null ? void 0 : r.size) || 400}`, t = await fetch(c, { headers: I }).then((a) => a.json());
1010
+ return V({
997
1011
  data: t.data.rewards
998
1012
  });
999
1013
  }
1000
1014
  );
1001
- async function Oe(e, a, c) {
1015
+ async function We(e, r, c) {
1002
1016
  var s;
1003
1017
  const t = await b({
1004
1018
  ...c,
1005
1019
  cacheTime: g
1006
- }), r = await V({
1020
+ }), a = await S({
1007
1021
  ...c,
1008
1022
  cacheTime: g
1009
1023
  }), n = /* @__PURE__ */ new Map();
1010
- for (const u of a) {
1024
+ for (const u of r) {
1011
1025
  const { rewardCoinType: l, ruleIds: p } = u;
1012
1026
  for (const w of p) {
1013
1027
  n.has(l) || n.set(l, { assetIds: [], ruleIds: [], amount: 0 });
1014
- const m = n.get(l);
1015
- m.assetIds.push(u.assetCoinType.replace("0x", "")), m.ruleIds.push(w), m.amount += u.userClaimableReward;
1028
+ const f = n.get(l);
1029
+ f.assetIds.push(u.assetCoinType.replace("0x", "")), f.ruleIds.push(w), f.amount += u.userClaimableReward;
1016
1030
  }
1017
1031
  }
1018
1032
  const o = [];
1019
1033
  for (const [u, { assetIds: l, ruleIds: p, amount: w }] of n) {
1020
- const m = r.find(
1021
- (j) => f(j.suiCoinType) === f(u)
1034
+ const f = a.find(
1035
+ (j) => m(j.suiCoinType) === m(u)
1022
1036
  );
1023
- if (!m || !m.contract.rewardFundId)
1037
+ if (!f || !f.contract.rewardFundId)
1024
1038
  throw new Error(`No matching rewardFund found for reward coin: ${u}`);
1025
- const y = m.contract.rewardFundId;
1039
+ const y = f.contract.rewardFundId;
1026
1040
  if (c != null && c.accountCap && !c.customCoinReceive)
1027
1041
  throw new Error("customCoinReceive is required when accountCap is provided");
1028
1042
  if (c != null && c.customCoinReceive) {
@@ -1078,15 +1092,15 @@ async function Oe(e, a, c) {
1078
1092
  );
1079
1093
  }
1080
1094
  if ((c == null ? void 0 : c.customCoinReceive.type) === "depositNAVI") {
1081
- const U = T(m.totalSupplyAmount).shiftedBy(-9), O = T(m.supplyCapCeiling).shiftedBy(-27);
1082
- U.plus(w).isGreaterThan(O) && ((s = c == null ? void 0 : c.customCoinReceive.depositNAVI) != null && s.fallbackReceiveAddress) ? e.transferObjects(
1095
+ const H = T(f.totalSupplyAmount).shiftedBy(-9), G = T(f.supplyCapCeiling).shiftedBy(-27);
1096
+ H.plus(w).isGreaterThan(G) && ((s = c == null ? void 0 : c.customCoinReceive.depositNAVI) != null && s.fallbackReceiveAddress) ? e.transferObjects(
1083
1097
  [_],
1084
1098
  e.pure.address(c.customCoinReceive.depositNAVI.fallbackReceiveAddress)
1085
- ) : await te(e, m, _, c);
1099
+ ) : await oe(e, f, _, c);
1086
1100
  } else
1087
1101
  o.push({
1088
1102
  coin: _,
1089
- identifier: m
1103
+ identifier: f
1090
1104
  });
1091
1105
  } else
1092
1106
  e.moveCall({
@@ -1110,9 +1124,9 @@ async function Oe(e, a, c) {
1110
1124
  }
1111
1125
  return o;
1112
1126
  }
1113
- async function Ge(e, a) {
1127
+ async function Je(e, r) {
1114
1128
  const c = await b({
1115
- ...a
1129
+ ...r
1116
1130
  });
1117
1131
  return e.moveCall({
1118
1132
  target: `${c.package}::lending::create_account`,
@@ -1120,53 +1134,53 @@ async function Ge(e, a) {
1120
1134
  });
1121
1135
  }
1122
1136
  export {
1123
- F as Address,
1137
+ R as Address,
1124
1138
  g as DEFAULT_CACHE_TIME,
1125
- be as FlashLoanAssetConfig,
1126
- fe as IncentiveAPYInfo,
1127
- Y as IncentivePoolInfo,
1128
- ge as IncentivePoolInfoByPhase,
1129
- ye as OracleInfo,
1130
- $ as PoolOperator,
1131
- we as ReserveDataInfo,
1132
- Q as UserStateInfo,
1133
- Ce as borrowCoinPTB,
1134
- Oe as claimLendingRewardsPTB,
1135
- Ge as createAccountCapPTB,
1136
- te as depositCoinPTB,
1137
- Se as filterPriceFeeds,
1138
- Re as flashloanPTB,
1139
- S as getAllFlashLoanAssets,
1140
- Te as getBorrowFee,
1141
- Pe as getCoins,
1139
+ Ce as FlashLoanAssetConfig,
1140
+ he as IncentiveAPYInfo,
1141
+ Z as IncentivePoolInfo,
1142
+ ve as IncentivePoolInfoByPhase,
1143
+ je as OracleInfo,
1144
+ k as PoolOperator,
1145
+ _e as ReserveDataInfo,
1146
+ x as UserStateInfo,
1147
+ $e as borrowCoinPTB,
1148
+ We as claimLendingRewardsPTB,
1149
+ Je as createAccountCapPTB,
1150
+ oe as depositCoinPTB,
1151
+ Ue as filterPriceFeeds,
1152
+ Le as flashloanPTB,
1153
+ F as getAllFlashLoanAssets,
1154
+ Be as getBorrowFee,
1155
+ Ne as getCoins,
1142
1156
  b as getConfig,
1143
- ve as getFees,
1144
- Fe as getFlashLoanAsset,
1145
- $e as getHealthFactor,
1146
- ae as getHealthFactorPTB,
1147
- Ie as getLendingState,
1157
+ Ae as getFees,
1158
+ De as getFlashLoanAsset,
1159
+ Se as getHealthFactor,
1160
+ se as getHealthFactorPTB,
1161
+ Ve as getLendingState,
1148
1162
  v as getPool,
1149
- V as getPools,
1150
- ne as getPriceFeeds,
1151
- re as getPythStalePriceFeedId,
1152
- ke as getSimulatedHealthFactor,
1153
- L as getSimulatedHealthFactorPTB,
1154
- he as getStats,
1155
- Be as getTransactions,
1156
- De as getUserAvailableLendingRewards,
1157
- Ue as getUserClaimedRewardHistory,
1158
- Me as getUserTotalClaimedReward,
1159
- Ee as liquidatePTB,
1160
- Ae as mergeCoinsPTB,
1161
- f as normalizeCoinType,
1163
+ S as getPools,
1164
+ le as getPriceFeeds,
1165
+ ie as getPythStalePriceFeedId,
1166
+ Fe as getSimulatedHealthFactor,
1167
+ O as getSimulatedHealthFactorPTB,
1168
+ Te as getStats,
1169
+ Re as getTransactions,
1170
+ qe as getUserAvailableLendingRewards,
1171
+ ze as getUserClaimedRewardHistory,
1172
+ Ge as getUserTotalClaimedReward,
1173
+ Oe as liquidatePTB,
1174
+ Pe as mergeCoinsPTB,
1175
+ m as normalizeCoinType,
1162
1176
  d as parseTxValue,
1163
- _e as repayCoinPTB,
1164
- Ne as repayFlashLoanPTB,
1165
- Le as summaryLendingRewards,
1166
- Ve as updateOraclePricesPTB,
1167
- ce as updatePythPriceFeeds,
1168
- I as withCache,
1177
+ ke as repayCoinPTB,
1178
+ Me as repayFlashLoanPTB,
1179
+ He as summaryLendingRewards,
1180
+ Ee as updateOraclePricesPTB,
1181
+ ue as updatePythPriceFeeds,
1182
+ $ as withCache,
1169
1183
  C as withSingleton,
1170
- je as withdrawCoinPTB
1184
+ Ie as withdrawCoinPTB
1171
1185
  };
1172
1186
  //# sourceMappingURL=index.esm.js.map