@naviprotocol/lending 2.1.0 → 2.2.0-preview.20261029.f4ae850

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.
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,SAAS,EACT,IAAI,EACJ,WAAW,IAAI,eAAe,EAC9B,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,SAAS,EAET,aAAa,EACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAoBtD,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAAW,YAAY,EAAY,MAAM,QAAQ,CAAA;AA6BxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,CAAC;IACN,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IACjC,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,UAAU,CAAC,EAAE,EACjB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,OAwIF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,2BAA2B,CAC/C,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,iBAAiB,EAChD,UAAU,EAAE,eAAe,EAC3B,eAAe,EAAE,MAAM,GAA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C,OAAO,CAAC,QAAQ;IAYT,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAc5C,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM;IAqC9C,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM;IAqC/C,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM;IAqC7C,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM;IAqCnD,OAAO,CAAC,eAAe;IAUvB,oBAAoB,CAAC,SAAS,EAAE,eAAe,EAAE;;;;;;;;;;;;;CAmIlD;AAED,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,iBAAiB,EAChD,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC,iBAkB5C"}
package/dist/account.js CHANGED
@@ -1,13 +1,13 @@
1
- import { Transaction as O } from "@mysten/sui/transactions";
1
+ import { Transaction as j } from "@mysten/sui/transactions";
2
2
  import { ReserveDataInfo as J, UserStateInfo as Z } from "./bcs.js";
3
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";
4
+ import { withCache as R, withSingleton as Q, parseTxPoolValue as X, parseTxValue as T, suiClient as N, devInspectTransaction as O, 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
5
  import { bcs as V } from "@mysten/sui/bcs";
6
6
  import { getPool as W, PoolOperator as U, getPools as te } from "./pool.js";
7
7
  import oe from "./package.json.js";
8
8
  import { getUserEModeCaps as ne } from "./emode.js";
9
9
  import l from "bignumber.js";
10
- import { MARKETS as q, getMarketConfig as D } from "./market.js";
10
+ import { loadMarketConfigs as q, getMarketConfig as D } from "./market.js";
11
11
  import { resolveNaviOpenApiEndpoint as re, buildNaviOpenApiUrl as ie, mergeServiceHeaders as ae } from "./services.js";
12
12
  function se(n, e) {
13
13
  return n.coinType ? n.coinType : e || (typeof n.type == "string" ? n.type.match(/::coin::Coin<(.+)>$/) : null)?.[1];
@@ -25,7 +25,7 @@ function be(n, e, o) {
25
25
  let u = 0;
26
26
  const t = [];
27
27
  let c = "", p = 0n;
28
- e.sort((w, N) => Number(N.balance) - Number(w.balance)).forEach((w) => {
28
+ e.sort((w, $) => Number($.balance) - Number(w.balance)).forEach((w) => {
29
29
  if (p += BigInt(w.balance), !(i && u >= r) && Number(w.balance) !== 0) {
30
30
  if (c || (c = w.coinType), c !== w.coinType)
31
31
  throw new Error("All coins must be of the same type");
@@ -40,7 +40,7 @@ function be(n, e, o) {
40
40
  } catch {
41
41
  return !1;
42
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;
43
+ })(c || d || "") && !!o?.useGasCoin, s = BigInt(r), m = !y && !!d, v = m ? a : 0n, B = p + v, b = !i || p >= s ? 0n : s - p, k = m && b > 0n && v >= b;
44
44
  if (i && B < s)
45
45
  throw new Error(`Balance is less than the specified balance: ${B} < ${s}`);
46
46
  if (t.length === 0 && !k)
@@ -89,11 +89,16 @@ async function G(n, e, o, i, r, a, u) {
89
89
  async function le(n, e, o) {
90
90
  return G(n, e, 0, 0, 0, !1, o);
91
91
  }
92
- async function K(n, e, o) {
93
- const i = new O(), r = o?.client ?? j, a = await te({
92
+ async function z(n, e, o) {
93
+ const i = new j(), r = o?.client ?? N, a = await te({
94
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));
95
+ markets: await q({
96
+ env: o?.env,
97
+ services: o?.services
98
+ })
99
+ }), u = ee(a), c = Array.from(new Set(e.map((s) => s.market))).map(
100
+ (s) => D(s, { env: o?.env || "prod" })
101
+ );
97
102
  for (const s of c) {
98
103
  const m = await E({
99
104
  ...o,
@@ -116,71 +121,74 @@ async function K(n, e, o) {
116
121
  arguments: [i.object(m.storage), i.pure.address(s.address)]
117
122
  });
118
123
  }
119
- const d = (await $(r, {
124
+ const d = (await O(r, {
120
125
  transactionBlock: i,
121
126
  sender: n
122
- })).results || [], v = {};
127
+ })).results || [], g = {};
123
128
  c.forEach((s, m) => {
124
129
  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)
130
+ const v = d[m]?.returnValues?.map((b) => V.vector(J).parse(Uint8Array.from(b[0])))[0] || [], B = {};
131
+ for (const b of v)
127
132
  B[b.id] = {
128
133
  supplyIndex: b.supply_index,
129
134
  borrowIndex: b.borrow_index
130
135
  };
131
- v[s.key] = B;
132
- } catch (f) {
136
+ g[s.key] = B;
137
+ } catch (v) {
133
138
  console.warn(
134
139
  `[@naviprotocol/lending] Failed to decode reserve data for market "${s.key}", falling back to open-api pool indices`,
135
- f
140
+ v
136
141
  );
137
142
  }
138
143
  });
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] || {};
144
+ const f = d.slice(c.length).map((s) => s.returnValues?.map((m) => V.vector(Z).parse(Uint8Array.from(m[0])))[0] || []), y = [];
145
+ return f.forEach((s, m) => {
146
+ const v = e[m], B = D(v.market, { env: o?.env || "prod" }), b = g[B.key] || {};
142
147
  s.forEach((k) => {
143
- if (k.supply_balance === "0" && k.borrow_balance === "0" && (f.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
148
+ if (k.supply_balance === "0" && k.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
144
149
  return;
145
150
  const I = u[`${B.key}-${k.asset_id}`];
146
151
  if (!I)
147
152
  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();
153
+ const C = b[k.asset_id], S = C?.supplyIndex ?? I.currentSupplyIndex, w = C?.borrowIndex ?? I.currentBorrowIndex, $ = L(k.supply_balance, S).toString(), K = L(k.borrow_balance, w).toString();
149
154
  y.push({
150
- supplyBalance: N,
151
- borrowBalance: z,
155
+ supplyBalance: $,
156
+ borrowBalance: K,
152
157
  assetId: k.asset_id,
153
158
  market: B.key,
154
159
  pool: I,
155
- emodeId: f.emodeId
160
+ emodeId: v.emodeId
156
161
  });
157
162
  });
158
163
  }), y;
159
164
  }
160
165
  const ke = R(
161
166
  async (n, e) => {
162
- const i = (e?.markets || Object.keys(q)).map((r) => D(r)).map((r) => ({
167
+ const i = (e?.markets || await q({
168
+ env: e?.env,
169
+ services: e?.services
170
+ })).map((r) => D(r, { env: e?.env || "prod" })).map((r) => ({
163
171
  address: n,
164
172
  market: r.key
165
173
  }));
166
- return await K(n, i, e);
174
+ return await z(n, i, e);
167
175
  }
168
176
  );
169
177
  async function Be(n, e) {
170
- const o = e?.client ?? j, i = new O();
178
+ const o = e?.client ?? N, i = new j();
171
179
  await le(i, n, e);
172
- const r = await $(o, {
180
+ const r = await O(o, {
173
181
  transactionBlock: i,
174
182
  sender: n
175
183
  }), a = F(r, [V.u256()]);
176
184
  return H(Number(a[0]) || 0);
177
185
  }
178
186
  async function Ce(n, e, o, i) {
179
- const r = i?.client ?? j, a = new O();
187
+ const r = i?.client ?? N, a = new j();
180
188
  let u = 0, t = 0;
181
189
  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);
190
+ if (o.forEach((f) => {
191
+ f.type === U.Supply ? u += f.amount : f.type === U.Withdraw ? u -= f.amount : f.type === U.Borrow ? t += f.amount : f.type === U.Repay && (t -= f.amount);
184
192
  }), u * t < 0)
185
193
  throw new Error("Invalid operations");
186
194
  const p = u > 0 || t > 0;
@@ -193,11 +201,11 @@ async function Ce(n, e, o, i) {
193
201
  p,
194
202
  i
195
203
  );
196
- const d = await $(r, {
204
+ const d = await O(r, {
197
205
  transactionBlock: a,
198
206
  sender: n
199
- }), v = F(d, [V.u256()]);
200
- return H(Number(v[0]) || 0);
207
+ }), g = F(d, [V.u256()]);
208
+ return H(Number(g[0]) || 0);
201
209
  }
202
210
  const Ie = Q(
203
211
  async (n, e) => {
@@ -214,7 +222,7 @@ const Ie = Q(
214
222
  );
215
223
  async function Se(n, e) {
216
224
  let o = null;
217
- const i = [], r = e?.client ?? j, a = r.core;
225
+ const i = [], r = e?.client ?? N, a = r.core;
218
226
  do {
219
227
  let u;
220
228
  if (e?.coinType)
@@ -256,15 +264,15 @@ async function Se(n, e) {
256
264
  for (const p of t) {
257
265
  let d = null;
258
266
  do {
259
- const v = await a.listCoins({
267
+ const g = await a.listCoins({
260
268
  owner: n,
261
269
  coinType: p,
262
270
  cursor: d,
263
271
  limit: 100
264
272
  });
265
273
  i.push(
266
- ...(v.objects ?? v.data ?? []).map((g) => x(g, p)).filter(Boolean)
267
- ), d = v.cursor ?? v.nextCursor ?? null;
274
+ ...(g.objects ?? g.data ?? []).map((f) => x(f, p)).filter(Boolean)
275
+ ), d = g.cursor ?? g.nextCursor ?? null;
268
276
  } while (d);
269
277
  }
270
278
  break;
@@ -287,27 +295,30 @@ async function Se(n, e) {
287
295
  }
288
296
  const Te = R(
289
297
  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) => ({
298
+ const o = [], i = (e?.markets || await q({
299
+ env: e?.env,
300
+ services: e?.services
301
+ })).map((t) => D(t, { env: e?.env || "prod" })), r = await ne(n, e), a = i.map((t) => ({
291
302
  address: n,
292
303
  market: t.key
293
304
  })).concat(
294
305
  r.filter((t) => !!i.find((c) => c.id === t.marketId)).map((t) => ({
295
306
  address: t.accountCap,
296
- market: D(t.marketId).key,
307
+ market: D(t.marketId, { env: e?.env || "prod" }).key,
297
308
  emodeId: t.emodeId
298
309
  }))
299
310
  );
300
- return (await K(n, a, e)).forEach((t) => {
311
+ return (await z(n, a, e)).forEach((t) => {
301
312
  const c = typeof t.emodeId == "number" ? r.find((p) => {
302
- const d = D(t.market);
313
+ const d = D(t.market, { env: e?.env || "prod" });
303
314
  return p.emodeId === t.emodeId && p.marketId === d.id;
304
315
  }) : void 0;
305
316
  if (c) {
306
317
  if (!t.pool.emodes.find((d) => d.emodeId === c.emodeId))
307
318
  return;
308
319
  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)
320
+ const d = l(t.supplyBalance).shiftedBy(-9).decimalPlaces(t.pool.token.decimals, l.ROUND_DOWN), g = M(t.pool, c);
321
+ if (d.gt(0) || g.emode.isCollateral)
311
322
  try {
312
323
  o.push({
313
324
  id: `${t.pool.uniqueId}_${c.emodeId}_navi-lending-emode-supply-${h()}`,
@@ -323,13 +334,13 @@ const Te = R(
323
334
  emodeCap: c
324
335
  }
325
336
  });
326
- } catch (g) {
327
- console.error(g);
337
+ } catch (f) {
338
+ console.error(f);
328
339
  }
329
340
  }
330
341
  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)
342
+ const d = l(t.borrowBalance).shiftedBy(-9).decimalPlaces(t.pool.token.decimals, l.ROUND_DOWN), g = M(t.pool, c);
343
+ if (d.gt(0) || g.emode.isDebt)
333
344
  try {
334
345
  o.push({
335
346
  id: `${t.pool.uniqueId}_${c.emodeId}_navi-lending-emode-borrow-${h()}`,
@@ -345,8 +356,8 @@ const Te = R(
345
356
  emodeCap: c
346
357
  }
347
358
  });
348
- } catch (g) {
349
- console.error(g);
359
+ } catch (f) {
360
+ console.error(f);
350
361
  }
351
362
  }
352
363
  } else {
@@ -574,11 +585,11 @@ class _ {
574
585
  } else if (y.type === "navi-lending-emode-supply") {
575
586
  const s = y["navi-lending-emode-supply"], m = this.resolveValueUSD(s);
576
587
  r = r.plus(m);
577
- const f = s.pool.emode;
588
+ const v = s.pool.emode;
578
589
  c = c.plus(
579
- new l(m).multipliedBy(f.lt)
590
+ new l(m).multipliedBy(v.lt)
580
591
  ), p = p.plus(
581
- new l(m).multipliedBy(f.ltv)
592
+ new l(m).multipliedBy(v.ltv)
582
593
  );
583
594
  } else if (y.type === "navi-lending-emode-borrow") {
584
595
  const s = y["navi-lending-emode-borrow"];
@@ -586,32 +597,32 @@ class _ {
586
597
  }
587
598
  }), a = l.max(a, 0), r = l.max(r, 0), c = l.max(c, 0), p = l.max(p, 0), e.forEach((y) => {
588
599
  if (y.type === "navi-lending-supply") {
589
- const s = y["navi-lending-supply"], m = this.resolveValueUSD(s), f = s.pool.supplyIncentiveApyInfo.apy;
600
+ const s = y["navi-lending-supply"], m = this.resolveValueUSD(s), v = s.pool.supplyIncentiveApyInfo.apy;
590
601
  r.gt(0) && (u = u.plus(
591
- new l(m).dividedBy(r).multipliedBy(new l(f).dividedBy(100))
602
+ new l(m).dividedBy(r).multipliedBy(new l(v).dividedBy(100))
592
603
  )), o[s.pool.suiCoinType] = l(o[s.pool.suiCoinType] || 0).plus(s.amount).toString();
593
604
  } else if (y.type === "navi-lending-borrow") {
594
- const s = y["navi-lending-borrow"], m = this.resolveValueUSD(s), f = s.pool.borrowIncentiveApyInfo.apy;
605
+ const s = y["navi-lending-borrow"], m = this.resolveValueUSD(s), v = s.pool.borrowIncentiveApyInfo.apy;
595
606
  a.gt(0) && (t = t.plus(
596
- new l(m).dividedBy(a).multipliedBy(new l(f).dividedBy(100))
607
+ new l(m).dividedBy(a).multipliedBy(new l(v).dividedBy(100))
597
608
  )), i[s.pool.suiCoinType] = l(i[s.pool.suiCoinType] || 0).plus(s.amount).toString();
598
609
  } 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;
610
+ const s = y["navi-lending-emode-supply"], m = this.resolveValueUSD(s), v = s.pool.supplyIncentiveApyInfo.apy;
600
611
  r.gt(0) && (u = u.plus(
601
- new l(m).dividedBy(r).multipliedBy(new l(f).dividedBy(100))
612
+ new l(m).dividedBy(r).multipliedBy(new l(v).dividedBy(100))
602
613
  )), o[s.pool.suiCoinType] = l(o[s.pool.suiCoinType] || 0).plus(s.amount).toString();
603
614
  } 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;
615
+ const s = y["navi-lending-emode-borrow"], m = this.resolveValueUSD(s), v = s.pool.borrowIncentiveApyInfo.apy;
605
616
  a.gt(0) && (t = t.plus(
606
- new l(m).dividedBy(a).multipliedBy(new l(f).dividedBy(100))
617
+ new l(m).dividedBy(a).multipliedBy(new l(v).dividedBy(100))
607
618
  )), i[s.pool.suiCoinType] = l(i[s.pool.suiCoinType] || 0).plus(s.amount).toString();
608
619
  }
609
620
  });
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));
621
+ const d = r.minus(a), g = r.minus(a).eq(0) ? new l(0) : r.multipliedBy(u).minus(a.multipliedBy(t)).div(r.minus(a));
611
622
  return {
612
623
  hf: a.toNumber() !== 0 ? c.dividedBy(a).toNumber() : 1 / 0,
613
624
  netVaule: d.toString(),
614
- netWorthApr: v.toString(),
625
+ netWorthApr: g.toString(),
615
626
  totalSupplyValue: r.toString(),
616
627
  totalBorrowValue: a.toString(),
617
628
  totalsupplyApy: u.toString(),