@naviprotocol/lending 2.0.5-dev.0 → 2.0.6

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.
Files changed (56) hide show
  1. package/dist/account-cap.d.ts +1 -1
  2. package/dist/account.d.ts +2 -2
  3. package/dist/config.d.ts +1 -1
  4. package/dist/emode.d.ts +1 -1
  5. package/dist/flashloan.d.ts +1 -1
  6. package/dist/index.d.ts +17 -17
  7. package/dist/index.esm.js +2749 -0
  8. package/dist/index.esm.js.map +1 -0
  9. package/dist/liquidate.d.ts +1 -1
  10. package/dist/market.d.ts +1 -1
  11. package/dist/oracle.d.ts +2 -2
  12. package/dist/oracle.d.ts.map +1 -1
  13. package/dist/pool.d.ts +1 -1
  14. package/dist/pyth.d.ts +1 -1
  15. package/dist/reward.d.ts +1 -1
  16. package/dist/sui.d.ts +1 -1
  17. package/dist/types.d.ts +6 -2
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/utils.d.ts +2 -2
  20. package/package.json +5 -5
  21. package/dist/account-cap.js +0 -26
  22. package/dist/account-cap.js.map +0 -1
  23. package/dist/account.js +0 -655
  24. package/dist/account.js.map +0 -1
  25. package/dist/bcs.js +0 -137
  26. package/dist/bcs.js.map +0 -1
  27. package/dist/config.js +0 -22
  28. package/dist/config.js.map +0 -1
  29. package/dist/emode.js +0 -90
  30. package/dist/emode.js.map +0 -1
  31. package/dist/flashloan.js +0 -94
  32. package/dist/flashloan.js.map +0 -1
  33. package/dist/index.js +0 -100
  34. package/dist/index.js.map +0 -1
  35. package/dist/liquidate.js +0 -76
  36. package/dist/liquidate.js.map +0 -1
  37. package/dist/market.js +0 -121
  38. package/dist/market.js.map +0 -1
  39. package/dist/oracle.js +0 -198
  40. package/dist/oracle.js.map +0 -1
  41. package/dist/package.json.js +0 -8
  42. package/dist/package.json.js.map +0 -1
  43. package/dist/pool.js +0 -391
  44. package/dist/pool.js.map +0 -1
  45. package/dist/pyth.js +0 -305
  46. package/dist/pyth.js.map +0 -1
  47. package/dist/reward.js +0 -343
  48. package/dist/reward.js.map +0 -1
  49. package/dist/services.js +0 -52
  50. package/dist/services.js.map +0 -1
  51. package/dist/sui.js +0 -121
  52. package/dist/sui.js.map +0 -1
  53. package/dist/ua.js +0 -16
  54. package/dist/ua.js.map +0 -1
  55. package/dist/utils.js +0 -227
  56. package/dist/utils.js.map +0 -1
package/dist/account.js DELETED
@@ -1,655 +0,0 @@
1
- import { Transaction as O } from "@mysten/sui/transactions";
2
- import { ReserveDataInfo as J, UserStateInfo as Z } from "./bcs.js";
3
- import { getConfig as E, DEFAULT_CACHE_TIME as A } from "./config.js";
4
- import { withCache as R, withSingleton as Q, parseTxPoolValue as X, parseTxValue as T, suiClient as j, devInspectTransaction as $, parseDevInspectResult as F, processContractHealthFactor as H, requestHeaders as Y, poolToEModePool as M, uuid as h, normalizeCoinType as P, getPoolsMap as ee, rayMathMulIndex as L } from "./utils.js";
5
- import { bcs as V } from "@mysten/sui/bcs";
6
- import { getPool as W, PoolOperator as U, getPools as te } from "./pool.js";
7
- import oe from "./package.json.js";
8
- import { getUserEModeCaps as ne } from "./emode.js";
9
- import l from "bignumber.js";
10
- import { MARKETS as q, getMarketConfig as D } from "./market.js";
11
- import { resolveNaviOpenApiEndpoint as re, buildNaviOpenApiUrl as ie, mergeServiceHeaders as ae } from "./services.js";
12
- function se(n, e) {
13
- return n.coinType ? n.coinType : e || (typeof n.type == "string" ? n.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
14
- }
15
- function x(n, e) {
16
- const o = se(n, e), i = n.coinObjectId ?? n.objectId;
17
- return !o || !i || n.balance === void 0 || n.balance === null ? null : {
18
- ...n,
19
- coinType: P(o),
20
- coinObjectId: i
21
- };
22
- }
23
- function be(n, e, o) {
24
- const i = typeof o?.balance == "number", r = i ? o.balance : 0, a = BigInt(o?.addressBalance ?? 0);
25
- let u = 0;
26
- const t = [];
27
- let c = "", p = 0n;
28
- e.sort((w, N) => Number(N.balance) - Number(w.balance)).forEach((w) => {
29
- if (p += BigInt(w.balance), !(i && u >= r) && Number(w.balance) !== 0) {
30
- if (c || (c = w.coinType), c !== w.coinType)
31
- throw new Error("All coins must be of the same type");
32
- u += Number(w.balance), t.push(w.coinObjectId);
33
- }
34
- });
35
- const d = o?.coinType, y = ((w) => {
36
- if (!w)
37
- return !1;
38
- try {
39
- return P(w) === P("0x2::sui::SUI");
40
- } catch {
41
- return !1;
42
- }
43
- })(c || d || "") && !!o?.useGasCoin, s = BigInt(r), m = !y && !!d, f = m ? a : 0n, B = p + f, b = !i || p >= s ? 0n : s - p, k = m && b > 0n && f >= b;
44
- if (i && B < s)
45
- throw new Error(`Balance is less than the specified balance: ${B} < ${s}`);
46
- if (t.length === 0 && !k)
47
- throw new Error("No coins to merge");
48
- if (y)
49
- return i ? n.splitCoins(n.gas, [n.pure.u64(r)]) : n.gas;
50
- if (!k)
51
- return t.length === 1 ? n.object(t[0]) : n.mergeCoins(t[0], t.slice(1)), i ? n.splitCoins(t[0], [n.pure.u64(r)]) : t[0];
52
- const I = n.moveCall({
53
- target: "0x2::coin::redeem_funds",
54
- typeArguments: [d],
55
- arguments: [n.withdrawal({ amount: b, type: d })]
56
- });
57
- let C;
58
- const S = [];
59
- if (t.length > 0) {
60
- C = n.object(t[0]);
61
- for (const w of t.slice(1))
62
- S.push(n.object(w));
63
- S.push(I);
64
- } else
65
- C = I;
66
- return S.length > 0 && n.mergeCoins(C, S), t.length === 0 ? C : i ? n.splitCoins(C, [n.pure.u64(r)]) : C;
67
- }
68
- async function G(n, e, o, i, r, a, u) {
69
- const t = await E({
70
- ...u,
71
- cacheTime: A
72
- }), c = await W(o, u);
73
- return n.moveCall({
74
- target: `${t.uiGetter}::calculator_unchecked::dynamic_health_factor`,
75
- arguments: [
76
- n.object("0x06"),
77
- n.object(t.storage),
78
- n.object(t.oracle.priceOracle),
79
- X(n, c),
80
- T(e, n.pure.address),
81
- T(c.id, n.pure.u8),
82
- T(i, n.pure.u64),
83
- T(r, n.pure.u64),
84
- T(a, n.pure.bool)
85
- ],
86
- typeArguments: [c.suiCoinType]
87
- });
88
- }
89
- async function le(n, e, o) {
90
- return G(n, e, 0, 0, 0, !1, o);
91
- }
92
- async function K(n, e, o) {
93
- const i = new O(), r = o?.client ?? j, a = await te({
94
- ...o,
95
- markets: Object.values(q)
96
- }), u = ee(a), c = Array.from(new Set(e.map((s) => s.market))).map((s) => D(s));
97
- for (const s of c) {
98
- const m = await E({
99
- ...o,
100
- cacheTime: A,
101
- market: s.key
102
- });
103
- i.moveCall({
104
- target: `${m.uiGetter}::getter::get_reserve_data`,
105
- arguments: [i.object(m.storage)]
106
- });
107
- }
108
- for (let s of e) {
109
- const m = await E({
110
- ...o,
111
- cacheTime: A,
112
- market: s.market
113
- });
114
- i.moveCall({
115
- target: `${m.uiGetter}::getter_unchecked::get_user_state`,
116
- arguments: [i.object(m.storage), i.pure.address(s.address)]
117
- });
118
- }
119
- const d = (await $(r, {
120
- transactionBlock: i,
121
- sender: n
122
- })).results || [], v = {};
123
- c.forEach((s, m) => {
124
- try {
125
- const f = d[m]?.returnValues?.map((b) => V.vector(J).parse(Uint8Array.from(b[0])))[0] || [], B = {};
126
- for (const b of f)
127
- B[b.id] = {
128
- supplyIndex: b.supply_index,
129
- borrowIndex: b.borrow_index
130
- };
131
- v[s.key] = B;
132
- } catch (f) {
133
- console.warn(
134
- `[@naviprotocol/lending] Failed to decode reserve data for market "${s.key}", falling back to open-api pool indices`,
135
- f
136
- );
137
- }
138
- });
139
- const g = d.slice(c.length).map((s) => s.returnValues?.map((m) => V.vector(Z).parse(Uint8Array.from(m[0])))[0] || []), y = [];
140
- return g.forEach((s, m) => {
141
- const f = e[m], B = D(f.market), b = v[B.key] || {};
142
- s.forEach((k) => {
143
- if (k.supply_balance === "0" && k.borrow_balance === "0" && (f.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
144
- return;
145
- const I = u[`${B.key}-${k.asset_id}`];
146
- if (!I)
147
- return;
148
- const C = b[k.asset_id], S = C?.supplyIndex ?? I.currentSupplyIndex, w = C?.borrowIndex ?? I.currentBorrowIndex, N = L(k.supply_balance, S).toString(), z = L(k.borrow_balance, w).toString();
149
- y.push({
150
- supplyBalance: N,
151
- borrowBalance: z,
152
- assetId: k.asset_id,
153
- market: B.key,
154
- pool: I,
155
- emodeId: f.emodeId
156
- });
157
- });
158
- }), y;
159
- }
160
- const ke = R(
161
- async (n, e) => {
162
- const i = (e?.markets || Object.keys(q)).map((r) => D(r)).map((r) => ({
163
- address: n,
164
- market: r.key
165
- }));
166
- return await K(n, i, e);
167
- }
168
- );
169
- async function Be(n, e) {
170
- const o = e?.client ?? j, i = new O();
171
- await le(i, n, e);
172
- const r = await $(o, {
173
- transactionBlock: i,
174
- sender: n
175
- }), a = F(r, [V.u256()]);
176
- return H(Number(a[0]) || 0);
177
- }
178
- async function Ce(n, e, o, i) {
179
- const r = i?.client ?? j, a = new O();
180
- let u = 0, t = 0;
181
- const c = await W(e, i);
182
- if (o.forEach((g) => {
183
- g.type === U.Supply ? u += g.amount : g.type === U.Withdraw ? u -= g.amount : g.type === U.Borrow ? t += g.amount : g.type === U.Repay && (t -= g.amount);
184
- }), u * t < 0)
185
- throw new Error("Invalid operations");
186
- const p = u > 0 || t > 0;
187
- await G(
188
- a,
189
- n,
190
- c,
191
- Math.abs(u),
192
- Math.abs(t),
193
- p,
194
- i
195
- );
196
- const d = await $(r, {
197
- transactionBlock: a,
198
- sender: n
199
- }), v = F(d, [V.u256()]);
200
- return H(Number(v[0]) || 0);
201
- }
202
- const Ie = Q(
203
- async (n, e) => {
204
- const o = new URLSearchParams();
205
- e?.cursor && o.set("cursor", e.cursor), o.set("userAddress", n);
206
- const i = re(e), r = ie(
207
- `/navi/user/transactions?${o.toString()}&sdk=${oe.version}`,
208
- e
209
- );
210
- return (await fetch(r, {
211
- headers: ae(Y, i)
212
- }).then((u) => u.json())).data;
213
- }
214
- );
215
- async function Se(n, e) {
216
- let o = null;
217
- const i = [], r = e?.client ?? j, a = r.core;
218
- do {
219
- let u;
220
- if (e?.coinType)
221
- if (typeof a?.listCoins == "function") {
222
- const t = await a.listCoins({
223
- owner: n,
224
- coinType: e?.coinType,
225
- cursor: o,
226
- limit: 100
227
- });
228
- u = {
229
- data: (t.objects ?? t.data ?? []).map((c) => x(c, e?.coinType)).filter(Boolean),
230
- nextCursor: t.cursor ?? t.nextCursor ?? null,
231
- hasNextPage: t.hasNextPage ?? !1
232
- };
233
- } else {
234
- if (typeof r.getCoins != "function")
235
- throw new Error("getCoins requires core.listCoins or an explicit legacy getCoins client");
236
- u = await r.getCoins({
237
- owner: n,
238
- coinType: e?.coinType,
239
- cursor: o,
240
- limit: 100
241
- });
242
- }
243
- else if (typeof a?.listBalances == "function" && typeof a?.listCoins == "function") {
244
- const t = /* @__PURE__ */ new Set();
245
- let c = null;
246
- do {
247
- const p = await a.listBalances({
248
- owner: n,
249
- cursor: c,
250
- limit: 100
251
- });
252
- for (const d of p.balances ?? [])
253
- d?.coinType && t.add(d.coinType);
254
- c = p.cursor ?? p.nextCursor ?? null;
255
- } while (c);
256
- for (const p of t) {
257
- let d = null;
258
- do {
259
- const v = await a.listCoins({
260
- owner: n,
261
- coinType: p,
262
- cursor: d,
263
- limit: 100
264
- });
265
- i.push(
266
- ...(v.objects ?? v.data ?? []).map((g) => x(g, p)).filter(Boolean)
267
- ), d = v.cursor ?? v.nextCursor ?? null;
268
- } while (d);
269
- }
270
- break;
271
- } else {
272
- if (typeof r.getAllCoins != "function")
273
- throw new Error(
274
- "getCoins requires core.listBalances/core.listCoins or an explicit legacy getAllCoins client"
275
- );
276
- u = await r.getAllCoins({
277
- owner: n,
278
- cursor: o,
279
- limit: 100
280
- });
281
- }
282
- if (!u.data || !u.data.length)
283
- break;
284
- i.push(...u.data), o = u.nextCursor;
285
- } while (o);
286
- return i;
287
- }
288
- const Te = R(
289
- async (n, e) => {
290
- const o = [], i = (e?.markets || Object.keys(q)).map((t) => D(t)), r = await ne(n, e), a = i.map((t) => ({
291
- address: n,
292
- market: t.key
293
- })).concat(
294
- r.filter((t) => !!i.find((c) => c.id === t.marketId)).map((t) => ({
295
- address: t.accountCap,
296
- market: D(t.marketId).key,
297
- emodeId: t.emodeId
298
- }))
299
- );
300
- return (await K(n, a, e)).forEach((t) => {
301
- const c = typeof t.emodeId == "number" ? r.find((p) => {
302
- const d = D(t.market);
303
- return p.emodeId === t.emodeId && p.marketId === d.id;
304
- }) : void 0;
305
- if (c) {
306
- if (!t.pool.emodes.find((d) => d.emodeId === c.emodeId))
307
- return;
308
- if (l(t.supplyBalance).gte(0)) {
309
- const d = l(t.supplyBalance).shiftedBy(-9).decimalPlaces(t.pool.token.decimals, l.ROUND_DOWN), v = M(t.pool, c);
310
- if (d.gt(0) || v.emode.isCollateral)
311
- try {
312
- o.push({
313
- id: `${t.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${h()}`,
314
- wallet: n,
315
- protocol: "navi",
316
- market: t.market,
317
- type: "navi-lending-emode-supply",
318
- "navi-lending-emode-supply": {
319
- amount: d.toString(),
320
- pool: M(t.pool, c),
321
- token: t.pool.token,
322
- valueUSD: d.multipliedBy(t.pool.oracle.price).toString(),
323
- emodeCap: c
324
- }
325
- });
326
- } catch (g) {
327
- console.error(g);
328
- }
329
- }
330
- if (l(t.borrowBalance).gte(0)) {
331
- const d = l(t.borrowBalance).shiftedBy(-9).decimalPlaces(t.pool.token.decimals, l.ROUND_DOWN), v = M(t.pool, c);
332
- if (d.gt(0) || v.emode.isDebt)
333
- try {
334
- o.push({
335
- id: `${t.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${h()}`,
336
- wallet: n,
337
- protocol: "navi",
338
- market: t.market,
339
- type: "navi-lending-emode-borrow",
340
- "navi-lending-emode-borrow": {
341
- amount: d.toString(),
342
- pool: M(t.pool, c),
343
- token: t.pool.token,
344
- valueUSD: d.multipliedBy(t.pool.oracle.price).toString(),
345
- emodeCap: c
346
- }
347
- });
348
- } catch (g) {
349
- console.error(g);
350
- }
351
- }
352
- } else {
353
- if (l(t.supplyBalance).gt(0)) {
354
- const p = l(t.supplyBalance).shiftedBy(-9).decimalPlaces(t.pool.token.decimals, l.ROUND_DOWN);
355
- o.push({
356
- id: `${t.pool.uniqueId}_navi-lending-supply-${h()}`,
357
- wallet: n,
358
- protocol: "navi",
359
- type: "navi-lending-supply",
360
- market: t.market,
361
- "navi-lending-supply": {
362
- amount: p.toString(),
363
- pool: t.pool,
364
- token: t.pool.token,
365
- valueUSD: p.multipliedBy(t.pool.oracle.price).toString()
366
- }
367
- });
368
- }
369
- if (l(t.borrowBalance).gt(0)) {
370
- const p = l(t.borrowBalance).shiftedBy(-9).decimalPlaces(t.pool.token.decimals, l.ROUND_DOWN);
371
- o.push({
372
- id: `${t.pool.uniqueId}_navi-lending-borrow-${h()}`,
373
- wallet: n,
374
- protocol: "navi",
375
- market: t.market,
376
- type: "navi-lending-borrow",
377
- "navi-lending-borrow": {
378
- amount: p.toString(),
379
- pool: t.pool,
380
- token: t.pool.token,
381
- valueUSD: p.multipliedBy(t.pool.oracle.price).toString()
382
- }
383
- });
384
- }
385
- }
386
- }), o;
387
- }
388
- );
389
- class _ {
390
- constructor(e, o) {
391
- this._positions = [], this._priceMap = {}, this._overview = {
392
- hf: 1 / 0,
393
- netVaule: "0",
394
- netWorthApr: "0",
395
- totalSupplyValue: "0",
396
- totalBorrowValue: "0",
397
- totalsupplyApy: "0",
398
- totalBorrowApy: "0",
399
- maxLiquidationValue: "0",
400
- maxLoanToVaule: "0",
401
- supply: {},
402
- borrow: {}
403
- }, this._priceMap = o || {}, this.positions = e;
404
- }
405
- get positions() {
406
- return this._positions;
407
- }
408
- get overview() {
409
- return this._overview;
410
- }
411
- get priceMap() {
412
- return this._priceMap;
413
- }
414
- set positions(e) {
415
- this._positions = e, this._overview = this.getPositionsOverview(e);
416
- }
417
- updatePriceMap(e) {
418
- return this._priceMap = e, this._overview = this.getPositionsOverview(this._positions), this;
419
- }
420
- getPrice(e) {
421
- const o = P(e.suiCoinType);
422
- if (this._priceMap[o] !== void 0)
423
- return this._priceMap[o].toString();
424
- const i = e.suiCoinType;
425
- return this._priceMap[i] !== void 0 ? this._priceMap[i].toString() : e.oracle.price;
426
- }
427
- filterPositionsByPool(e) {
428
- const i = !!e.isEMode ? ["navi-lending-emode-supply", "navi-lending-emode-borrow"] : ["navi-lending-supply", "navi-lending-borrow"];
429
- return new _(
430
- this.positions.filter((r) => {
431
- const a = r[r.type];
432
- return i.includes(r.type) && a.pool.uniqueId === e.uniqueId;
433
- }),
434
- this._priceMap
435
- );
436
- }
437
- deposit(e, o) {
438
- const i = !!e.isEMode, r = this.getPrice(e);
439
- let a;
440
- return i ? a = {
441
- id: h(),
442
- wallet: "",
443
- protocol: "navi",
444
- market: "",
445
- type: "navi-lending-emode-supply",
446
- "navi-lending-emode-supply": {
447
- amount: o.toString(),
448
- valueUSD: l(o).multipliedBy(r).toString(),
449
- token: e.token,
450
- pool: e,
451
- emodeCap: {}
452
- }
453
- } : a = {
454
- id: h(),
455
- wallet: "",
456
- protocol: "navi",
457
- market: "",
458
- type: "navi-lending-supply",
459
- "navi-lending-supply": {
460
- amount: o.toString(),
461
- valueUSD: l(o).multipliedBy(r).toString(),
462
- token: e.token,
463
- pool: e
464
- }
465
- }, new _([...this.positions, a], this._priceMap);
466
- }
467
- withdraw(e, o) {
468
- const i = !!e.isEMode, r = this.getPrice(e);
469
- let a;
470
- return i ? a = {
471
- id: h(),
472
- wallet: "",
473
- protocol: "navi",
474
- market: "",
475
- type: "navi-lending-emode-supply",
476
- "navi-lending-emode-supply": {
477
- amount: (-o).toString(),
478
- valueUSD: l(-o).multipliedBy(r).toString(),
479
- token: e.token,
480
- pool: e,
481
- emodeCap: {}
482
- }
483
- } : a = {
484
- id: h(),
485
- wallet: "",
486
- protocol: "navi",
487
- market: "",
488
- type: "navi-lending-supply",
489
- "navi-lending-supply": {
490
- amount: (-o).toString(),
491
- valueUSD: l(-o).multipliedBy(r).toString(),
492
- token: e.token,
493
- pool: e
494
- }
495
- }, new _([...this.positions, a], this._priceMap);
496
- }
497
- borrow(e, o) {
498
- const i = !!e.isEMode, r = this.getPrice(e);
499
- let a;
500
- return i ? a = {
501
- id: h(),
502
- wallet: "",
503
- protocol: "navi",
504
- market: "",
505
- type: "navi-lending-emode-borrow",
506
- "navi-lending-emode-borrow": {
507
- amount: o.toString(),
508
- valueUSD: l(o).multipliedBy(r).toString(),
509
- token: e.token,
510
- pool: e,
511
- emodeCap: {}
512
- }
513
- } : a = {
514
- id: h(),
515
- wallet: "",
516
- protocol: "navi",
517
- market: "",
518
- type: "navi-lending-borrow",
519
- "navi-lending-borrow": {
520
- amount: o.toString(),
521
- valueUSD: l(o).multipliedBy(r).toString(),
522
- token: e.token,
523
- pool: e
524
- }
525
- }, new _([...this.positions, a], this._priceMap);
526
- }
527
- repay(e, o) {
528
- const i = !!e.isEMode, r = this.getPrice(e);
529
- let a;
530
- return i ? a = {
531
- id: h(),
532
- wallet: "",
533
- protocol: "navi",
534
- market: "",
535
- type: "navi-lending-emode-borrow",
536
- "navi-lending-emode-borrow": {
537
- amount: (-o).toString(),
538
- valueUSD: l(-o).multipliedBy(r).toString(),
539
- token: e.token,
540
- pool: e,
541
- emodeCap: {}
542
- }
543
- } : a = {
544
- id: h(),
545
- wallet: "",
546
- protocol: "navi",
547
- market: "",
548
- type: "navi-lending-borrow",
549
- "navi-lending-borrow": {
550
- amount: (-o).toString(),
551
- valueUSD: l(-o).multipliedBy(r).toString(),
552
- token: e.token,
553
- pool: e
554
- }
555
- }, new _([...this.positions, a], this._priceMap);
556
- }
557
- resolveValueUSD(e) {
558
- return Object.keys(this._priceMap).length > 0 ? l(e.amount).multipliedBy(this.getPrice(e.pool)).toString() : e.valueUSD;
559
- }
560
- getPositionsOverview(e) {
561
- const o = {}, i = {};
562
- let r = new l(0), a = new l(0), u = new l(0), t = new l(0), c = new l(0), p = new l(0);
563
- e.forEach((y) => {
564
- if (y.type === "navi-lending-supply") {
565
- const s = y["navi-lending-supply"], m = this.resolveValueUSD(s);
566
- r = r.plus(m), c = c.plus(
567
- new l(m).multipliedBy(s.pool.liquidationFactor.threshold)
568
- ), p = p.plus(
569
- new l(m).multipliedBy(s.pool.ltvValue)
570
- );
571
- } else if (y.type === "navi-lending-borrow") {
572
- const s = y["navi-lending-borrow"];
573
- a = a.plus(this.resolveValueUSD(s));
574
- } else if (y.type === "navi-lending-emode-supply") {
575
- const s = y["navi-lending-emode-supply"], m = this.resolveValueUSD(s);
576
- r = r.plus(m);
577
- const f = s.pool.emode;
578
- c = c.plus(
579
- new l(m).multipliedBy(f.lt)
580
- ), p = p.plus(
581
- new l(m).multipliedBy(f.ltv)
582
- );
583
- } else if (y.type === "navi-lending-emode-borrow") {
584
- const s = y["navi-lending-emode-borrow"];
585
- a = a.plus(this.resolveValueUSD(s));
586
- }
587
- }), a = l.max(a, 0), r = l.max(r, 0), c = l.max(c, 0), p = l.max(p, 0), e.forEach((y) => {
588
- if (y.type === "navi-lending-supply") {
589
- const s = y["navi-lending-supply"], m = this.resolveValueUSD(s), f = s.pool.supplyIncentiveApyInfo.apy;
590
- r.gt(0) && (u = u.plus(
591
- new l(m).dividedBy(r).multipliedBy(new l(f).dividedBy(100))
592
- )), o[s.pool.suiCoinType] = l(o[s.pool.suiCoinType] || 0).plus(s.amount).toString();
593
- } else if (y.type === "navi-lending-borrow") {
594
- const s = y["navi-lending-borrow"], m = this.resolveValueUSD(s), f = s.pool.borrowIncentiveApyInfo.apy;
595
- a.gt(0) && (t = t.plus(
596
- new l(m).dividedBy(a).multipliedBy(new l(f).dividedBy(100))
597
- )), i[s.pool.suiCoinType] = l(i[s.pool.suiCoinType] || 0).plus(s.amount).toString();
598
- } else if (y.type === "navi-lending-emode-supply") {
599
- const s = y["navi-lending-emode-supply"], m = this.resolveValueUSD(s), f = s.pool.supplyIncentiveApyInfo.apy;
600
- r.gt(0) && (u = u.plus(
601
- new l(m).dividedBy(r).multipliedBy(new l(f).dividedBy(100))
602
- )), o[s.pool.suiCoinType] = l(o[s.pool.suiCoinType] || 0).plus(s.amount).toString();
603
- } else if (y.type === "navi-lending-emode-borrow") {
604
- const s = y["navi-lending-emode-borrow"], m = this.resolveValueUSD(s), f = s.pool.borrowIncentiveApyInfo.apy;
605
- a.gt(0) && (t = t.plus(
606
- new l(m).dividedBy(a).multipliedBy(new l(f).dividedBy(100))
607
- )), i[s.pool.suiCoinType] = l(i[s.pool.suiCoinType] || 0).plus(s.amount).toString();
608
- }
609
- });
610
- const d = r.minus(a), v = r.minus(a).eq(0) ? new l(0) : r.multipliedBy(u).minus(a.multipliedBy(t)).div(r.minus(a));
611
- return {
612
- hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
613
- netVaule: d.toString(),
614
- netWorthApr: v.toString(),
615
- totalSupplyValue: r.toString(),
616
- totalBorrowValue: a.toString(),
617
- totalsupplyApy: u.toString(),
618
- totalBorrowApy: t.toString(),
619
- maxLiquidationValue: c.toString(),
620
- maxLoanToVaule: p.toString(),
621
- supply: o,
622
- borrow: i
623
- };
624
- }
625
- }
626
- async function _e(n, e, o, i) {
627
- const r = await E({
628
- ...i,
629
- cacheTime: A
630
- });
631
- r.limter && n.moveCall({
632
- target: `${r.limter}::navi_adaptor::verify_navi_position_healthy`,
633
- arguments: [
634
- n.object("0x06"),
635
- n.object(r.storage),
636
- n.object(r.priceOracle),
637
- T(e, n.pure.address),
638
- n.pure.u256(new l(o).shiftedBy(27).toNumber())
639
- ]
640
- });
641
- }
642
- export {
643
- _ as UserPositions,
644
- Se as getCoins,
645
- Be as getHealthFactor,
646
- le as getHealthFactorPTB,
647
- Te as getLendingPositions,
648
- ke as getLendingState,
649
- Ce as getSimulatedHealthFactor,
650
- G as getSimulatedHealthFactorPTB,
651
- Ie as getTransactions,
652
- be as mergeCoinsPTB,
653
- _e as verifyHealthFactorPTB
654
- };
655
- //# sourceMappingURL=account.js.map