@naviprotocol/lending 1.4.1-dev.1 → 1.4.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/account.d.ts +1 -1
- package/dist/account.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +231 -221
- package/dist/index.esm.js.map +1 -1
- package/dist/market.d.ts +9 -0
- package/dist/market.d.ts.map +1 -1
- package/dist/oracle.d.ts.map +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction as
|
|
1
|
+
import { Transaction as N } from "@mysten/sui/transactions";
|
|
2
2
|
import { bcs as m, toHex as ie, fromHex as ce } from "@mysten/bcs";
|
|
3
3
|
import { SuiClient as se, getFullnodeUrl as ue } from "@mysten/sui/client";
|
|
4
4
|
import le from "lodash.camelcase";
|
|
@@ -129,7 +129,7 @@ const z = m.bytes(32).transform({
|
|
|
129
129
|
borrow_balance: m.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: m.u256()
|
|
132
|
-
}), ye = "1.4.1
|
|
132
|
+
}), ye = "1.4.1", V = {
|
|
133
133
|
version: ye
|
|
134
134
|
}, ge = V.version, he = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node)
|
|
@@ -151,8 +151,8 @@ function Q(e) {
|
|
|
151
151
|
return e.forEach((o, r) => {
|
|
152
152
|
const t = r === e.length - 1;
|
|
153
153
|
if (typeof o == "object" && o !== null && t) {
|
|
154
|
-
const { client: a, disableCache:
|
|
155
|
-
n.push(
|
|
154
|
+
const { client: a, disableCache: c, cacheTime: i, ...s } = o;
|
|
155
|
+
n.push(s);
|
|
156
156
|
} else
|
|
157
157
|
n.push(o);
|
|
158
158
|
}), JSON.stringify(n);
|
|
@@ -170,10 +170,10 @@ function $(e) {
|
|
|
170
170
|
let n = {};
|
|
171
171
|
return (...o) => {
|
|
172
172
|
const r = o[o.length - 1], t = Q(o), a = n[t];
|
|
173
|
-
return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? a.data : e(...o).then((
|
|
174
|
-
data:
|
|
173
|
+
return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? a.data : e(...o).then((c) => (n[t] = {
|
|
174
|
+
data: c,
|
|
175
175
|
cacheAt: Date.now()
|
|
176
|
-
},
|
|
176
|
+
}, c));
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
function W(e) {
|
|
@@ -249,7 +249,7 @@ function ke(e) {
|
|
|
249
249
|
poolId: parseInt(o)
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function T() {
|
|
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 F = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(F || {});
|
|
@@ -260,16 +260,16 @@ const R = $(
|
|
|
260
260
|
(t) => t.key
|
|
261
261
|
)}`, r = await fetch(o, { headers: M }).then((t) => t.json());
|
|
262
262
|
return r.data.forEach((t) => {
|
|
263
|
-
const
|
|
263
|
+
const c = r.meta.emodes.filter((f) => {
|
|
264
264
|
const w = j(f.marketId);
|
|
265
265
|
return t.market === w.key && f.isActive;
|
|
266
266
|
}).filter((f) => !!f.assets.find((w) => w.assetId === t.id));
|
|
267
|
-
t.emodes =
|
|
268
|
-
const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(),
|
|
267
|
+
t.emodes = c;
|
|
268
|
+
const i = p(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), s = p(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), u = p(i).multipliedBy(t.oracle.price).toString(), d = p(s).multipliedBy(t.oracle.price).toString(), y = 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
271
|
).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), g = p(y).multipliedBy(t.oracle.price).toString(), l = p(v).multipliedBy(t.oracle.price).toString();
|
|
272
|
-
t.poolSupplyAmount = i, t.poolBorrowAmount =
|
|
272
|
+
t.poolSupplyAmount = i, t.poolBorrowAmount = s, t.poolSupplyValue = u, t.poolBorrowValue = d, t.poolSupplyCapAmount = y, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = g, t.poolBorrowCapValue = l;
|
|
273
273
|
}), r.data;
|
|
274
274
|
}
|
|
275
275
|
)
|
|
@@ -282,7 +282,7 @@ async function A(e, n) {
|
|
|
282
282
|
}
|
|
283
283
|
const r = await R({
|
|
284
284
|
...n,
|
|
285
|
-
markets: [o ||
|
|
285
|
+
markets: [o || D],
|
|
286
286
|
cacheTime: b
|
|
287
287
|
});
|
|
288
288
|
if (typeof e == "object")
|
|
@@ -310,10 +310,10 @@ async function _e(e, n, o, r) {
|
|
|
310
310
|
...r,
|
|
311
311
|
cacheTime: b
|
|
312
312
|
}), a = await A(n, r);
|
|
313
|
-
if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
|
|
313
|
+
if (r?.market, a?.deprecatedAt && Date.now() > a.deprecatedAt)
|
|
314
314
|
throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
|
|
315
|
-
const
|
|
316
|
-
if (k(a.suiCoinType) === k("0x2::sui::SUI") &&
|
|
315
|
+
const c = typeof o == "object" && o.$kind === "GasCoin";
|
|
316
|
+
if (k(a.suiCoinType) === k("0x2::sui::SUI") && c) {
|
|
317
317
|
if (!r?.amount)
|
|
318
318
|
throw new Error("Amount is required for sui coin");
|
|
319
319
|
o = e.splitCoins(o, [r.amount]);
|
|
@@ -349,7 +349,7 @@ async function _e(e, n, o, r) {
|
|
|
349
349
|
e.object(t.incentiveV3)
|
|
350
350
|
],
|
|
351
351
|
typeArguments: [a.suiCoinType]
|
|
352
|
-
}), t.version === 2 && a.
|
|
352
|
+
}), t.version === 2 && a.token.symbol === "SUI" && e.moveCall({
|
|
353
353
|
target: `${t.package}::pool::refresh_stake`,
|
|
354
354
|
arguments: [e.object(a.contract.pool), e.object("0x05")]
|
|
355
355
|
}), e;
|
|
@@ -358,7 +358,7 @@ async function Qe(e, n, o, r) {
|
|
|
358
358
|
const t = await _({
|
|
359
359
|
...r,
|
|
360
360
|
cacheTime: b
|
|
361
|
-
}), a = await A(n, r),
|
|
361
|
+
}), a = await A(n, r), c = h(o, e.pure.u64);
|
|
362
362
|
let i;
|
|
363
363
|
if (t.version === 1)
|
|
364
364
|
if (r?.accountCap) {
|
|
@@ -370,7 +370,7 @@ async function Qe(e, n, o, r) {
|
|
|
370
370
|
e.object(t.storage),
|
|
371
371
|
e.object(a.contract.pool),
|
|
372
372
|
e.pure.u8(a.id),
|
|
373
|
-
|
|
373
|
+
c,
|
|
374
374
|
e.object(t.incentiveV2),
|
|
375
375
|
e.object(t.incentiveV3),
|
|
376
376
|
h(r.accountCap, e.object)
|
|
@@ -387,7 +387,7 @@ async function Qe(e, n, o, r) {
|
|
|
387
387
|
e.object(t.storage),
|
|
388
388
|
e.object(a.contract.pool),
|
|
389
389
|
e.pure.u8(a.id),
|
|
390
|
-
|
|
390
|
+
c,
|
|
391
391
|
e.object(t.incentiveV2),
|
|
392
392
|
e.object(t.incentiveV3)
|
|
393
393
|
],
|
|
@@ -404,7 +404,7 @@ async function Qe(e, n, o, r) {
|
|
|
404
404
|
e.object(t.storage),
|
|
405
405
|
e.object(a.contract.pool),
|
|
406
406
|
e.pure.u8(a.id),
|
|
407
|
-
|
|
407
|
+
c,
|
|
408
408
|
e.object(t.incentiveV2),
|
|
409
409
|
e.object(t.incentiveV3),
|
|
410
410
|
h(r.accountCap, e.object),
|
|
@@ -422,7 +422,7 @@ async function Qe(e, n, o, r) {
|
|
|
422
422
|
e.object(t.storage),
|
|
423
423
|
e.object(a.contract.pool),
|
|
424
424
|
e.pure.u8(a.id),
|
|
425
|
-
|
|
425
|
+
c,
|
|
426
426
|
e.object(t.incentiveV2),
|
|
427
427
|
e.object(t.incentiveV3),
|
|
428
428
|
e.object("0x05")
|
|
@@ -444,7 +444,7 @@ async function Xe(e, n, o, r) {
|
|
|
444
444
|
}), a = await A(n, r);
|
|
445
445
|
if (a?.deprecatedAt && Date.now() > a.deprecatedAt)
|
|
446
446
|
throw new Error(`The lending pool for coinType ${a.suiCoinType} has been deprecated.`);
|
|
447
|
-
const
|
|
447
|
+
const c = h(o, e.pure.u64);
|
|
448
448
|
let i;
|
|
449
449
|
if (t.version === 1)
|
|
450
450
|
if (r?.accountCap) {
|
|
@@ -456,7 +456,7 @@ async function Xe(e, n, o, r) {
|
|
|
456
456
|
e.object(t.storage),
|
|
457
457
|
e.object(a.contract.pool),
|
|
458
458
|
e.pure.u8(a.id),
|
|
459
|
-
|
|
459
|
+
c,
|
|
460
460
|
e.object(t.incentiveV2),
|
|
461
461
|
e.object(t.incentiveV3),
|
|
462
462
|
h(r.accountCap, e.object)
|
|
@@ -473,7 +473,7 @@ async function Xe(e, n, o, r) {
|
|
|
473
473
|
e.object(t.storage),
|
|
474
474
|
e.object(a.contract.pool),
|
|
475
475
|
e.pure.u8(a.id),
|
|
476
|
-
|
|
476
|
+
c,
|
|
477
477
|
e.object(t.incentiveV2),
|
|
478
478
|
e.object(t.incentiveV3)
|
|
479
479
|
],
|
|
@@ -490,7 +490,7 @@ async function Xe(e, n, o, r) {
|
|
|
490
490
|
e.object(t.storage),
|
|
491
491
|
e.object(a.contract.pool),
|
|
492
492
|
e.pure.u8(a.id),
|
|
493
|
-
|
|
493
|
+
c,
|
|
494
494
|
e.object(t.incentiveV2),
|
|
495
495
|
e.object(t.incentiveV3),
|
|
496
496
|
h(r.accountCap, e.object),
|
|
@@ -508,7 +508,7 @@ async function Xe(e, n, o, r) {
|
|
|
508
508
|
e.object(t.storage),
|
|
509
509
|
e.object(a.contract.pool),
|
|
510
510
|
e.pure.u8(a.id),
|
|
511
|
-
|
|
511
|
+
c,
|
|
512
512
|
e.object(t.incentiveV2),
|
|
513
513
|
e.object(t.incentiveV3),
|
|
514
514
|
e.object("0x05")
|
|
@@ -527,8 +527,8 @@ async function xe(e, n, o, r) {
|
|
|
527
527
|
const t = await _({
|
|
528
528
|
...r,
|
|
529
529
|
cacheTime: b
|
|
530
|
-
}), a = await A(n, r),
|
|
531
|
-
if (k(a.suiCoinType) === k("0x2::sui::SUI") &&
|
|
530
|
+
}), a = await A(n, r), c = typeof o == "object" && o.$kind === "GasCoin";
|
|
531
|
+
if (k(a.suiCoinType) === k("0x2::sui::SUI") && c) {
|
|
532
532
|
if (!r?.amount)
|
|
533
533
|
throw new Error("Amount is required for sui coin");
|
|
534
534
|
o = e.splitCoins(o, [r.amount]);
|
|
@@ -539,7 +539,7 @@ async function xe(e, n, o, r) {
|
|
|
539
539
|
arguments: [h(o, e.object)],
|
|
540
540
|
typeArguments: [a.suiCoinType]
|
|
541
541
|
}), r?.accountCap) {
|
|
542
|
-
const [
|
|
542
|
+
const [s] = e.moveCall({
|
|
543
543
|
target: `${t.package}::incentive_v3::repay_with_account_cap`,
|
|
544
544
|
arguments: [
|
|
545
545
|
e.object("0x06"),
|
|
@@ -556,7 +556,7 @@ async function xe(e, n, o, r) {
|
|
|
556
556
|
});
|
|
557
557
|
return e.moveCall({
|
|
558
558
|
target: "0x2::coin::from_balance",
|
|
559
|
-
arguments: [
|
|
559
|
+
arguments: [s],
|
|
560
560
|
typeArguments: [a.suiCoinType]
|
|
561
561
|
});
|
|
562
562
|
} else
|
|
@@ -584,22 +584,22 @@ const et = $(
|
|
|
584
584
|
});
|
|
585
585
|
if (e?.address && typeof e?.asset < "u")
|
|
586
586
|
try {
|
|
587
|
-
const t = await A(e.asset, e), a = e?.client ?? P,
|
|
588
|
-
|
|
587
|
+
const t = await A(e.asset, e), a = e?.client ?? P, c = new N();
|
|
588
|
+
c.moveCall({
|
|
589
589
|
target: `${n.package}::incentive_v3::get_borrow_fee_v2`,
|
|
590
590
|
arguments: [
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
c.object(n.incentiveV3),
|
|
592
|
+
c.pure.address(e.address),
|
|
593
|
+
c.pure.u8(t.id),
|
|
594
|
+
c.pure.u64(1e4)
|
|
595
595
|
],
|
|
596
596
|
typeArguments: []
|
|
597
597
|
});
|
|
598
598
|
const i = await a.devInspectTransactionBlock({
|
|
599
|
-
transactionBlock:
|
|
599
|
+
transactionBlock: c,
|
|
600
600
|
sender: e.address
|
|
601
|
-
}),
|
|
602
|
-
return (Number(
|
|
601
|
+
}), s = L(i, [C.u64()]);
|
|
602
|
+
return (Number(s[0]) || 0) / 100;
|
|
603
603
|
} catch (t) {
|
|
604
604
|
console.error(t);
|
|
605
605
|
}
|
|
@@ -610,11 +610,16 @@ const et = $(
|
|
|
610
610
|
return Number(r) / 100;
|
|
611
611
|
}
|
|
612
612
|
)
|
|
613
|
-
),
|
|
613
|
+
), D = "main", E = {
|
|
614
614
|
main: {
|
|
615
615
|
id: 0,
|
|
616
616
|
key: "main",
|
|
617
617
|
name: "Main Market"
|
|
618
|
+
},
|
|
619
|
+
ember: {
|
|
620
|
+
id: 1,
|
|
621
|
+
key: "ember",
|
|
622
|
+
name: "Ember Market"
|
|
618
623
|
}
|
|
619
624
|
};
|
|
620
625
|
class Ce {
|
|
@@ -629,42 +634,42 @@ class Ce {
|
|
|
629
634
|
}
|
|
630
635
|
initPools(n) {
|
|
631
636
|
const o = H(this.pools), r = J(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
632
|
-
let
|
|
633
|
-
n.forEach((
|
|
634
|
-
if (!this.checkMarket(
|
|
635
|
-
console.warn(`Pool is not in market ${this.config.name}`,
|
|
637
|
+
let c = p(0), i = p(0);
|
|
638
|
+
n.forEach((s) => {
|
|
639
|
+
if (!this.checkMarket(s.market)) {
|
|
640
|
+
console.warn(`Pool is not in market ${this.config.name}`, s);
|
|
636
641
|
return;
|
|
637
642
|
}
|
|
638
|
-
o[
|
|
643
|
+
o[s.uniqueId] || this.pools.push(s), s?.emodes?.forEach((d) => {
|
|
639
644
|
r[d.uniqueId] || this.emodes.push(d), d.assets.forEach((y) => {
|
|
640
645
|
y.isDebt && d.assets.find(
|
|
641
|
-
(g) => g.isCollateral && g.ltv > 0 && g.assetId !==
|
|
642
|
-
) && t.add(
|
|
646
|
+
(g) => g.isCollateral && g.ltv > 0 && g.assetId !== s.id
|
|
647
|
+
) && t.add(s.uniqueId), y.isCollateral && d.assets.find((g) => g.isDebt && g.assetId !== s.id) && a.add(s.uniqueId);
|
|
643
648
|
});
|
|
644
|
-
}), i = i.plus(
|
|
645
|
-
}), this.poolMap = H(this.pools, "id"), this.emodeMap = J(this.emodes, "emodeId"), this.emodes.forEach((
|
|
646
|
-
const u = this.getEModePools(
|
|
649
|
+
}), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
|
|
650
|
+
}), this.poolMap = H(this.pools, "id"), this.emodeMap = J(this.emodes, "emodeId"), this.emodes.forEach((s) => {
|
|
651
|
+
const u = this.getEModePools(s.emodeId);
|
|
647
652
|
this.emodePools.push(...u);
|
|
648
653
|
}), this._overview = {
|
|
649
|
-
marketTotalSupplyValue:
|
|
654
|
+
marketTotalSupplyValue: c.toString(),
|
|
650
655
|
marketTotalBorrowValue: i.toString()
|
|
651
|
-
}, this.emodeBorrowablePools = this.pools.filter((
|
|
656
|
+
}, this.emodeBorrowablePools = this.pools.filter((s) => t.has(s.uniqueId)), this.emodeSupplyablePools = this.pools.filter((s) => a.has(s.uniqueId));
|
|
652
657
|
}
|
|
653
658
|
getEMode(n) {
|
|
654
659
|
return this.emodeMap[n] || null;
|
|
655
660
|
}
|
|
656
661
|
getEModeRelatePools(n, o) {
|
|
657
|
-
const { collateral: r, debt: t, emodeId: a } = o || {},
|
|
662
|
+
const { collateral: r, debt: t, emodeId: a } = o || {}, c = [];
|
|
658
663
|
return n.emodes.forEach((i) => {
|
|
659
|
-
typeof a == "number" && a !== i.emodeId || i.assets.forEach((
|
|
660
|
-
typeof r == "boolean" && r &&
|
|
664
|
+
typeof a == "number" && a !== i.emodeId || i.assets.forEach((s) => {
|
|
665
|
+
typeof r == "boolean" && r && s.isCollateral && s.assetId === n.id && c.push(this.poolMap[s.assetId]), typeof t == "boolean" && t && s.isDebt && s.assetId === n.id && c.push(this.poolMap[s.assetId]);
|
|
661
666
|
});
|
|
662
|
-
}),
|
|
667
|
+
}), c;
|
|
663
668
|
}
|
|
664
669
|
getEModePools(n) {
|
|
665
670
|
const o = this.getEMode(n);
|
|
666
671
|
return o ? o.assets.map((t) => t.assetId).map((t) => this.poolMap[t]).filter((t) => !!t).map((t) => {
|
|
667
|
-
const a = o.assets.find((
|
|
672
|
+
const a = o.assets.find((c) => c.assetId === t.id);
|
|
668
673
|
return {
|
|
669
674
|
...t,
|
|
670
675
|
emode: {
|
|
@@ -694,7 +699,7 @@ const j = (e) => {
|
|
|
694
699
|
markets: e
|
|
695
700
|
});
|
|
696
701
|
return e.map((r) => {
|
|
697
|
-
const t = j(r), a = o.filter((
|
|
702
|
+
const t = j(r), a = o.filter((c) => c.market === t.key);
|
|
698
703
|
return new Ce(r, a);
|
|
699
704
|
});
|
|
700
705
|
}
|
|
@@ -706,12 +711,12 @@ const j = (e) => {
|
|
|
706
711
|
), _ = $(
|
|
707
712
|
B(
|
|
708
713
|
async (e) => {
|
|
709
|
-
const n = j(e?.market ||
|
|
714
|
+
const n = j(e?.market || D), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${V.version}&market=${n.key}`;
|
|
710
715
|
return (await fetch(o, { headers: M }).then((t) => t.json())).data;
|
|
711
716
|
}
|
|
712
717
|
)
|
|
713
718
|
), b = 1e3 * 60 * 5;
|
|
714
|
-
async function
|
|
719
|
+
async function Ie(e, n) {
|
|
715
720
|
const o = await _({
|
|
716
721
|
cacheTime: b,
|
|
717
722
|
...n
|
|
@@ -721,7 +726,7 @@ async function Te(e, n) {
|
|
|
721
726
|
arguments: []
|
|
722
727
|
});
|
|
723
728
|
}
|
|
724
|
-
async function
|
|
729
|
+
async function Te(e, n, o) {
|
|
725
730
|
const r = await _({
|
|
726
731
|
cacheTime: b,
|
|
727
732
|
...o
|
|
@@ -765,17 +770,17 @@ async function nt(e, n, o) {
|
|
|
765
770
|
const r = await _({
|
|
766
771
|
cacheTime: b,
|
|
767
772
|
...o
|
|
768
|
-
}), t = await
|
|
773
|
+
}), t = await Ie(e, o);
|
|
769
774
|
await Be(e, n, {
|
|
770
775
|
...o,
|
|
771
776
|
accountCap: t
|
|
772
777
|
});
|
|
773
|
-
const a = await j(o?.market ||
|
|
778
|
+
const a = await j(o?.market || D), c = await Te(e, t, o);
|
|
774
779
|
return e.moveCall({
|
|
775
780
|
target: `${r.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
776
781
|
arguments: [
|
|
777
782
|
e.object(r.emode.contract.registryObject),
|
|
778
|
-
|
|
783
|
+
c,
|
|
779
784
|
h(a.id, e.pure.u64),
|
|
780
785
|
h(n, e.pure.u64)
|
|
781
786
|
]
|
|
@@ -787,18 +792,18 @@ const x = $(
|
|
|
787
792
|
const o = await _({
|
|
788
793
|
cacheTime: b,
|
|
789
794
|
...n
|
|
790
|
-
}), r = new
|
|
795
|
+
}), r = new N(), t = n?.client ?? P;
|
|
791
796
|
r.moveCall({
|
|
792
797
|
target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
793
798
|
arguments: [r.object(o.emode.contract.registryObject), r.pure.address(e)]
|
|
794
799
|
});
|
|
795
|
-
const
|
|
800
|
+
const c = (await t.devInspectTransactionBlock({
|
|
796
801
|
transactionBlock: r,
|
|
797
802
|
sender: e
|
|
798
|
-
})).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(
|
|
803
|
+
})).results[0].returnValues, i = C.vector(C.u64()).parse(Uint8Array.from(c[0][0])), s = C.vector(C.u64()).parse(Uint8Array.from(c[1][0])), u = C.vector(C.Address).parse(Uint8Array.from(c[2][0]));
|
|
799
804
|
return i.map((d, y) => ({
|
|
800
805
|
marketId: Number(d),
|
|
801
|
-
emodeId: Number(
|
|
806
|
+
emodeId: Number(s[y]),
|
|
802
807
|
accountCap: u[y].toString()
|
|
803
808
|
}));
|
|
804
809
|
}
|
|
@@ -810,51 +815,51 @@ function rt(e) {
|
|
|
810
815
|
function at(e, n, o) {
|
|
811
816
|
const r = typeof o?.balance == "number", t = r ? o.balance : 0;
|
|
812
817
|
let a = 0;
|
|
813
|
-
const
|
|
818
|
+
const c = [];
|
|
814
819
|
let i = "";
|
|
815
|
-
if (n.sort((
|
|
816
|
-
if (!(r && a >= t) && Number(
|
|
817
|
-
if (i || (i =
|
|
820
|
+
if (n.sort((s, u) => Number(u.balance) - Number(s.balance)).forEach((s) => {
|
|
821
|
+
if (!(r && a >= t) && Number(s.balance) !== 0) {
|
|
822
|
+
if (i || (i = s.coinType), i !== s.coinType)
|
|
818
823
|
throw new Error("All coins must be of the same type");
|
|
819
|
-
a += Number(
|
|
824
|
+
a += Number(s.balance), c.push(s.coinObjectId);
|
|
820
825
|
}
|
|
821
|
-
}),
|
|
826
|
+
}), c.length === 0)
|
|
822
827
|
throw new Error("No coins to merge");
|
|
823
828
|
if (r && a < t)
|
|
824
829
|
throw new Error(
|
|
825
830
|
`Balance is less than the specified balance: ${a} < ${t}`
|
|
826
831
|
);
|
|
827
|
-
return k(i) === k("0x2::sui::SUI") && o?.useGasCoin ? r ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (
|
|
832
|
+
return k(i) === k("0x2::sui::SUI") && o?.useGasCoin ? r ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (c.length === 1 ? e.object(c[0]) : e.mergeCoins(c[0], c.slice(1)), r ? e.splitCoins(c[0], [e.pure.u64(t)]) : c[0]);
|
|
828
833
|
}
|
|
829
|
-
async function ee(e, n, o, r, t, a,
|
|
834
|
+
async function ee(e, n, o, r, t, a, c) {
|
|
830
835
|
const i = await _({
|
|
831
|
-
...
|
|
836
|
+
...c,
|
|
832
837
|
cacheTime: b
|
|
833
|
-
}),
|
|
838
|
+
}), s = await A(o, c);
|
|
834
839
|
return e.moveCall({
|
|
835
840
|
target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
836
841
|
arguments: [
|
|
837
842
|
e.object("0x06"),
|
|
838
843
|
e.object(i.storage),
|
|
839
844
|
e.object(i.oracle.priceOracle),
|
|
840
|
-
we(e,
|
|
845
|
+
we(e, s),
|
|
841
846
|
h(n, e.pure.address),
|
|
842
|
-
h(
|
|
847
|
+
h(s.id, e.pure.u8),
|
|
843
848
|
h(r, e.pure.u64),
|
|
844
849
|
h(t, e.pure.u64),
|
|
845
850
|
h(a, e.pure.bool)
|
|
846
851
|
],
|
|
847
|
-
typeArguments: [
|
|
852
|
+
typeArguments: [s.suiCoinType]
|
|
848
853
|
});
|
|
849
854
|
}
|
|
850
855
|
async function Ae(e, n, o) {
|
|
851
856
|
return ee(e, n, 0, 0, 0, !1, o);
|
|
852
857
|
}
|
|
853
858
|
async function te(e, n, o) {
|
|
854
|
-
const r = new
|
|
859
|
+
const r = new N(), t = o?.client ?? P, a = await R({
|
|
855
860
|
...o,
|
|
856
861
|
markets: Object.values(E)
|
|
857
|
-
}),
|
|
862
|
+
}), c = H(a);
|
|
858
863
|
for (let d of n) {
|
|
859
864
|
const y = await _({
|
|
860
865
|
...o,
|
|
@@ -866,28 +871,28 @@ async function te(e, n, o) {
|
|
|
866
871
|
arguments: [r.object(y.storage), r.pure.address(d.address)]
|
|
867
872
|
});
|
|
868
873
|
}
|
|
869
|
-
const
|
|
874
|
+
const s = ((await t.devInspectTransactionBlock({
|
|
870
875
|
transactionBlock: r,
|
|
871
876
|
sender: e
|
|
872
877
|
})).results || []).map((d) => d.returnValues?.map((y) => C.vector(fe).parse(Uint8Array.from(y[0])))[0] || []), u = [];
|
|
873
|
-
return
|
|
878
|
+
return s.forEach((d, y) => {
|
|
874
879
|
const v = n[y], g = j(v.market);
|
|
875
880
|
d.forEach((l) => {
|
|
876
881
|
if (l.supply_balance === "0" && l.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
|
|
877
882
|
return;
|
|
878
|
-
const f =
|
|
883
|
+
const f = c[`${g.key}-${l.asset_id}`];
|
|
879
884
|
if (!f)
|
|
880
885
|
return;
|
|
881
886
|
const w = Y(
|
|
882
887
|
l.supply_balance,
|
|
883
888
|
f.currentSupplyIndex
|
|
884
|
-
).toString(),
|
|
889
|
+
).toString(), I = Y(
|
|
885
890
|
l.borrow_balance,
|
|
886
891
|
f.currentBorrowIndex
|
|
887
892
|
).toString();
|
|
888
893
|
u.push({
|
|
889
894
|
supplyBalance: w,
|
|
890
|
-
borrowBalance:
|
|
895
|
+
borrowBalance: I,
|
|
891
896
|
assetId: l.asset_id,
|
|
892
897
|
market: g.key,
|
|
893
898
|
pool: f,
|
|
@@ -906,7 +911,7 @@ const it = $(
|
|
|
906
911
|
}
|
|
907
912
|
);
|
|
908
913
|
async function ct(e, n) {
|
|
909
|
-
const o = n?.client ?? P, r = new
|
|
914
|
+
const o = n?.client ?? P, r = new N();
|
|
910
915
|
await Ae(r, e, n);
|
|
911
916
|
const t = await o.devInspectTransactionBlock({
|
|
912
917
|
transactionBlock: r,
|
|
@@ -915,19 +920,19 @@ async function ct(e, n) {
|
|
|
915
920
|
return X(Number(a[0]) || 0);
|
|
916
921
|
}
|
|
917
922
|
async function st(e, n, o, r) {
|
|
918
|
-
const t = r?.client ?? P, a = new
|
|
919
|
-
let
|
|
920
|
-
const
|
|
923
|
+
const t = r?.client ?? P, a = new N();
|
|
924
|
+
let c = 0, i = 0;
|
|
925
|
+
const s = await A(n, r);
|
|
921
926
|
if (o.forEach((v) => {
|
|
922
|
-
v.type === F.Supply ?
|
|
923
|
-
}),
|
|
927
|
+
v.type === F.Supply ? c += v.amount : v.type === F.Withdraw ? c -= v.amount : v.type === F.Borrow ? i += v.amount : v.type === F.Repay && (i -= v.amount);
|
|
928
|
+
}), c * i < 0)
|
|
924
929
|
throw new Error("Invalid operations");
|
|
925
|
-
const u =
|
|
930
|
+
const u = c > 0 || i > 0;
|
|
926
931
|
await ee(
|
|
927
932
|
a,
|
|
928
933
|
e,
|
|
929
|
-
|
|
930
|
-
Math.abs(
|
|
934
|
+
s,
|
|
935
|
+
Math.abs(c),
|
|
931
936
|
Math.abs(i),
|
|
932
937
|
u,
|
|
933
938
|
r
|
|
@@ -979,36 +984,36 @@ const $e = $(
|
|
|
979
984
|
address: e,
|
|
980
985
|
market: i.key
|
|
981
986
|
})).concat(
|
|
982
|
-
t.filter((i) => !!r.find((
|
|
987
|
+
t.filter((i) => !!r.find((s) => s.id === i.marketId)).map((i) => ({
|
|
983
988
|
address: i.accountCap,
|
|
984
989
|
market: j(i.marketId).key,
|
|
985
990
|
emodeId: i.emodeId
|
|
986
991
|
}))
|
|
987
992
|
);
|
|
988
993
|
return (await te(e, a, n)).forEach((i) => {
|
|
989
|
-
const
|
|
994
|
+
const s = typeof i.emodeId == "number" ? t.find((u) => {
|
|
990
995
|
const d = j(i.market);
|
|
991
996
|
return u.emodeId === i.emodeId && u.marketId === d.id;
|
|
992
997
|
}) : void 0;
|
|
993
|
-
if (
|
|
994
|
-
if (!i.pool.emodes.find((d) => d.emodeId ===
|
|
998
|
+
if (s) {
|
|
999
|
+
if (!i.pool.emodes.find((d) => d.emodeId === s.emodeId))
|
|
995
1000
|
return;
|
|
996
1001
|
if (p(i.supplyBalance).gte(0)) {
|
|
997
|
-
const d = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = q(i.pool,
|
|
1002
|
+
const d = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = q(i.pool, s);
|
|
998
1003
|
if (d.gt(0) || y.emode.isCollateral)
|
|
999
1004
|
try {
|
|
1000
1005
|
o.push({
|
|
1001
|
-
id: `${i.pool.uniqueId}_${
|
|
1006
|
+
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply-${T()}`,
|
|
1002
1007
|
wallet: e,
|
|
1003
1008
|
protocol: "navi",
|
|
1004
1009
|
market: i.market,
|
|
1005
1010
|
type: "navi-lending-emode-supply",
|
|
1006
1011
|
"navi-lending-emode-supply": {
|
|
1007
1012
|
amount: d.toString(),
|
|
1008
|
-
pool: q(i.pool,
|
|
1013
|
+
pool: q(i.pool, s),
|
|
1009
1014
|
token: i.pool.token,
|
|
1010
1015
|
valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
|
|
1011
|
-
emodeCap:
|
|
1016
|
+
emodeCap: s
|
|
1012
1017
|
}
|
|
1013
1018
|
});
|
|
1014
1019
|
} catch (v) {
|
|
@@ -1016,21 +1021,21 @@ const $e = $(
|
|
|
1016
1021
|
}
|
|
1017
1022
|
}
|
|
1018
1023
|
if (p(i.borrowBalance).gte(0)) {
|
|
1019
|
-
const d = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = q(i.pool,
|
|
1024
|
+
const d = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN), y = q(i.pool, s);
|
|
1020
1025
|
if (d.gt(0) || y.emode.isDebt)
|
|
1021
1026
|
try {
|
|
1022
1027
|
o.push({
|
|
1023
|
-
id: `${i.pool.uniqueId}_${
|
|
1028
|
+
id: `${i.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow-${T()}`,
|
|
1024
1029
|
wallet: e,
|
|
1025
1030
|
protocol: "navi",
|
|
1026
1031
|
market: i.market,
|
|
1027
1032
|
type: "navi-lending-emode-borrow",
|
|
1028
1033
|
"navi-lending-emode-borrow": {
|
|
1029
1034
|
amount: d.toString(),
|
|
1030
|
-
pool: q(i.pool,
|
|
1035
|
+
pool: q(i.pool, s),
|
|
1031
1036
|
token: i.pool.token,
|
|
1032
1037
|
valueUSD: d.multipliedBy(i.pool.oracle.price).toString(),
|
|
1033
|
-
emodeCap:
|
|
1038
|
+
emodeCap: s
|
|
1034
1039
|
}
|
|
1035
1040
|
});
|
|
1036
1041
|
} catch (v) {
|
|
@@ -1041,7 +1046,7 @@ const $e = $(
|
|
|
1041
1046
|
if (p(i.supplyBalance).gt(0)) {
|
|
1042
1047
|
const u = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1043
1048
|
o.push({
|
|
1044
|
-
id: `${i.pool.uniqueId}_navi-lending-supply-${
|
|
1049
|
+
id: `${i.pool.uniqueId}_navi-lending-supply-${T()}`,
|
|
1045
1050
|
wallet: e,
|
|
1046
1051
|
protocol: "navi",
|
|
1047
1052
|
type: "navi-lending-supply",
|
|
@@ -1057,7 +1062,7 @@ const $e = $(
|
|
|
1057
1062
|
if (p(i.borrowBalance).gt(0)) {
|
|
1058
1063
|
const u = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1059
1064
|
o.push({
|
|
1060
|
-
id: `${i.pool.uniqueId}_navi-lending-borrow-${
|
|
1065
|
+
id: `${i.pool.uniqueId}_navi-lending-borrow-${T()}`,
|
|
1061
1066
|
wallet: e,
|
|
1062
1067
|
protocol: "navi",
|
|
1063
1068
|
market: i.market,
|
|
@@ -1074,7 +1079,7 @@ const $e = $(
|
|
|
1074
1079
|
}), o;
|
|
1075
1080
|
}
|
|
1076
1081
|
);
|
|
1077
|
-
class
|
|
1082
|
+
class O {
|
|
1078
1083
|
constructor(n, o) {
|
|
1079
1084
|
this._positions = [], this._priceMap = {}, this._overview = {
|
|
1080
1085
|
hf: 1 / 0,
|
|
@@ -1114,7 +1119,7 @@ class U {
|
|
|
1114
1119
|
}
|
|
1115
1120
|
filterPositionsByPool(n) {
|
|
1116
1121
|
const r = !!n.isEMode ? ["navi-lending-emode-supply", "navi-lending-emode-borrow"] : ["navi-lending-supply", "navi-lending-borrow"];
|
|
1117
|
-
return new
|
|
1122
|
+
return new O(
|
|
1118
1123
|
this.positions.filter((t) => {
|
|
1119
1124
|
const a = t[t.type];
|
|
1120
1125
|
return r.includes(t.type) && a.pool.uniqueId === n.uniqueId;
|
|
@@ -1126,7 +1131,7 @@ class U {
|
|
|
1126
1131
|
const r = !!n.isEMode, t = this.getPrice(n);
|
|
1127
1132
|
let a;
|
|
1128
1133
|
return r ? a = {
|
|
1129
|
-
id:
|
|
1134
|
+
id: T(),
|
|
1130
1135
|
wallet: "",
|
|
1131
1136
|
protocol: "navi",
|
|
1132
1137
|
market: "",
|
|
@@ -1139,7 +1144,7 @@ class U {
|
|
|
1139
1144
|
emodeCap: {}
|
|
1140
1145
|
}
|
|
1141
1146
|
} : a = {
|
|
1142
|
-
id:
|
|
1147
|
+
id: T(),
|
|
1143
1148
|
wallet: "",
|
|
1144
1149
|
protocol: "navi",
|
|
1145
1150
|
market: "",
|
|
@@ -1150,13 +1155,13 @@ class U {
|
|
|
1150
1155
|
token: n.token,
|
|
1151
1156
|
pool: n
|
|
1152
1157
|
}
|
|
1153
|
-
}, new
|
|
1158
|
+
}, new O([...this.positions, a], this._priceMap);
|
|
1154
1159
|
}
|
|
1155
1160
|
withdraw(n, o) {
|
|
1156
1161
|
const r = !!n.isEMode, t = this.getPrice(n);
|
|
1157
1162
|
let a;
|
|
1158
1163
|
return r ? a = {
|
|
1159
|
-
id:
|
|
1164
|
+
id: T(),
|
|
1160
1165
|
wallet: "",
|
|
1161
1166
|
protocol: "navi",
|
|
1162
1167
|
market: "",
|
|
@@ -1169,7 +1174,7 @@ class U {
|
|
|
1169
1174
|
emodeCap: {}
|
|
1170
1175
|
}
|
|
1171
1176
|
} : a = {
|
|
1172
|
-
id:
|
|
1177
|
+
id: T(),
|
|
1173
1178
|
wallet: "",
|
|
1174
1179
|
protocol: "navi",
|
|
1175
1180
|
market: "",
|
|
@@ -1180,13 +1185,13 @@ class U {
|
|
|
1180
1185
|
token: n.token,
|
|
1181
1186
|
pool: n
|
|
1182
1187
|
}
|
|
1183
|
-
}, new
|
|
1188
|
+
}, new O([...this.positions, a], this._priceMap);
|
|
1184
1189
|
}
|
|
1185
1190
|
borrow(n, o) {
|
|
1186
1191
|
const r = !!n.isEMode, t = this.getPrice(n);
|
|
1187
1192
|
let a;
|
|
1188
1193
|
return r ? a = {
|
|
1189
|
-
id:
|
|
1194
|
+
id: T(),
|
|
1190
1195
|
wallet: "",
|
|
1191
1196
|
protocol: "navi",
|
|
1192
1197
|
market: "",
|
|
@@ -1199,7 +1204,7 @@ class U {
|
|
|
1199
1204
|
emodeCap: {}
|
|
1200
1205
|
}
|
|
1201
1206
|
} : a = {
|
|
1202
|
-
id:
|
|
1207
|
+
id: T(),
|
|
1203
1208
|
wallet: "",
|
|
1204
1209
|
protocol: "navi",
|
|
1205
1210
|
market: "",
|
|
@@ -1210,13 +1215,13 @@ class U {
|
|
|
1210
1215
|
token: n.token,
|
|
1211
1216
|
pool: n
|
|
1212
1217
|
}
|
|
1213
|
-
}, new
|
|
1218
|
+
}, new O([...this.positions, a], this._priceMap);
|
|
1214
1219
|
}
|
|
1215
1220
|
repay(n, o) {
|
|
1216
1221
|
const r = !!n.isEMode, t = this.getPrice(n);
|
|
1217
1222
|
let a;
|
|
1218
1223
|
return r ? a = {
|
|
1219
|
-
id:
|
|
1224
|
+
id: T(),
|
|
1220
1225
|
wallet: "",
|
|
1221
1226
|
protocol: "navi",
|
|
1222
1227
|
market: "",
|
|
@@ -1229,7 +1234,7 @@ class U {
|
|
|
1229
1234
|
emodeCap: {}
|
|
1230
1235
|
}
|
|
1231
1236
|
} : a = {
|
|
1232
|
-
id:
|
|
1237
|
+
id: T(),
|
|
1233
1238
|
wallet: "",
|
|
1234
1239
|
protocol: "navi",
|
|
1235
1240
|
market: "",
|
|
@@ -1240,18 +1245,18 @@ class U {
|
|
|
1240
1245
|
token: n.token,
|
|
1241
1246
|
pool: n
|
|
1242
1247
|
}
|
|
1243
|
-
}, new
|
|
1248
|
+
}, new O([...this.positions, a], this._priceMap);
|
|
1244
1249
|
}
|
|
1245
1250
|
resolveValueUSD(n) {
|
|
1246
1251
|
return Object.keys(this._priceMap).length > 0 ? p(n.amount).multipliedBy(this.getPrice(n.pool)).toString() : n.valueUSD;
|
|
1247
1252
|
}
|
|
1248
1253
|
getPositionsOverview(n) {
|
|
1249
1254
|
const o = {}, r = {};
|
|
1250
|
-
let t = new p(0), a = new p(0),
|
|
1255
|
+
let t = new p(0), a = new p(0), c = new p(0), i = new p(0), s = new p(0), u = new p(0);
|
|
1251
1256
|
n.forEach((g) => {
|
|
1252
1257
|
if (g.type === "navi-lending-supply") {
|
|
1253
1258
|
const l = g["navi-lending-supply"], f = this.resolveValueUSD(l);
|
|
1254
|
-
t = t.plus(f),
|
|
1259
|
+
t = t.plus(f), s = s.plus(
|
|
1255
1260
|
new p(f).multipliedBy(l.pool.liquidationFactor.threshold)
|
|
1256
1261
|
), u = u.plus(
|
|
1257
1262
|
new p(f).multipliedBy(l.pool.ltvValue)
|
|
@@ -1263,7 +1268,7 @@ class U {
|
|
|
1263
1268
|
const l = g["navi-lending-emode-supply"], f = this.resolveValueUSD(l);
|
|
1264
1269
|
t = t.plus(f);
|
|
1265
1270
|
const w = l.pool.emode;
|
|
1266
|
-
|
|
1271
|
+
s = s.plus(
|
|
1267
1272
|
new p(f).multipliedBy(w.lt)
|
|
1268
1273
|
), u = u.plus(
|
|
1269
1274
|
new p(f).multipliedBy(w.ltv)
|
|
@@ -1272,10 +1277,10 @@ class U {
|
|
|
1272
1277
|
const l = g["navi-lending-emode-borrow"];
|
|
1273
1278
|
a = a.plus(this.resolveValueUSD(l));
|
|
1274
1279
|
}
|
|
1275
|
-
}), a = p.max(a, 0), t = p.max(t, 0),
|
|
1280
|
+
}), a = p.max(a, 0), t = p.max(t, 0), s = p.max(s, 0), u = p.max(u, 0), n.forEach((g) => {
|
|
1276
1281
|
if (g.type === "navi-lending-supply") {
|
|
1277
1282
|
const l = g["navi-lending-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
|
|
1278
|
-
t.gt(0) && (
|
|
1283
|
+
t.gt(0) && (c = c.plus(
|
|
1279
1284
|
new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
|
|
1280
1285
|
)), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1281
1286
|
} else if (g.type === "navi-lending-borrow") {
|
|
@@ -1285,7 +1290,7 @@ class U {
|
|
|
1285
1290
|
)), r[l.pool.suiCoinType] = p(r[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1286
1291
|
} else if (g.type === "navi-lending-emode-supply") {
|
|
1287
1292
|
const l = g["navi-lending-emode-supply"], f = this.resolveValueUSD(l), w = l.pool.supplyIncentiveApyInfo.apy;
|
|
1288
|
-
t.gt(0) && (
|
|
1293
|
+
t.gt(0) && (c = c.plus(
|
|
1289
1294
|
new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
|
|
1290
1295
|
)), o[l.pool.suiCoinType] = p(o[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1291
1296
|
} else if (g.type === "navi-lending-emode-borrow") {
|
|
@@ -1295,16 +1300,16 @@ class U {
|
|
|
1295
1300
|
)), r[l.pool.suiCoinType] = p(r[l.pool.suiCoinType] || 0).plus(l.amount).toString();
|
|
1296
1301
|
}
|
|
1297
1302
|
});
|
|
1298
|
-
const d = t.minus(a), y = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(
|
|
1303
|
+
const d = t.minus(a), y = t.minus(a).eq(0) ? new p(0) : t.multipliedBy(c).minus(a.multipliedBy(i)).div(t.minus(a));
|
|
1299
1304
|
return {
|
|
1300
|
-
hf: a.toNumber() !== 0 ?
|
|
1305
|
+
hf: a.toNumber() !== 0 ? s.dividedBy(a).toNumber() : 1 / 0,
|
|
1301
1306
|
netVaule: d.toString(),
|
|
1302
1307
|
netWorthApr: y.toString(),
|
|
1303
1308
|
totalSupplyValue: t.toString(),
|
|
1304
1309
|
totalBorrowValue: a.toString(),
|
|
1305
|
-
totalsupplyApy:
|
|
1310
|
+
totalsupplyApy: c.toString(),
|
|
1306
1311
|
totalBorrowApy: i.toString(),
|
|
1307
|
-
maxLiquidationValue:
|
|
1312
|
+
maxLiquidationValue: s.toString(),
|
|
1308
1313
|
maxLoanToVaule: u.toString(),
|
|
1309
1314
|
supply: o,
|
|
1310
1315
|
borrow: r
|
|
@@ -1354,29 +1359,29 @@ async function dt(e) {
|
|
|
1354
1359
|
}
|
|
1355
1360
|
async function Pe(e, n) {
|
|
1356
1361
|
try {
|
|
1357
|
-
const o = [], r = n?.client ?? P, t = e.map((
|
|
1362
|
+
const o = [], r = n?.client ?? P, t = e.map((c) => c.priceInfoObject), a = await r.multiGetObjects({
|
|
1358
1363
|
ids: Array.from(new Set(t)),
|
|
1359
1364
|
options: { showContent: !0 }
|
|
1360
1365
|
});
|
|
1361
|
-
for (const
|
|
1362
|
-
const i =
|
|
1366
|
+
for (const c of a) {
|
|
1367
|
+
const i = c.data;
|
|
1363
1368
|
if (!i || !i.content || i.content.dataType !== "moveObject") {
|
|
1364
1369
|
console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
|
|
1365
1370
|
continue;
|
|
1366
1371
|
}
|
|
1367
|
-
const
|
|
1368
|
-
if (!
|
|
1372
|
+
const s = e.find((l) => l.priceInfoObject == i.objectId);
|
|
1373
|
+
if (!s) {
|
|
1369
1374
|
console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
|
|
1370
1375
|
continue;
|
|
1371
1376
|
}
|
|
1372
1377
|
const u = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: d, negative: y } = u.price.fields, v = u.conf, g = u.timestamp;
|
|
1373
1378
|
o.push({
|
|
1374
|
-
priceFeedId:
|
|
1375
|
-
priceInfoObject:
|
|
1379
|
+
priceFeedId: s.priceFeedId,
|
|
1380
|
+
priceInfoObject: s.priceInfoObject,
|
|
1376
1381
|
price: y ? "-" + d : d,
|
|
1377
1382
|
conf: v,
|
|
1378
1383
|
publishTime: Number(g),
|
|
1379
|
-
expiration:
|
|
1384
|
+
expiration: s.expiration
|
|
1380
1385
|
});
|
|
1381
1386
|
}
|
|
1382
1387
|
return o;
|
|
@@ -1397,8 +1402,8 @@ async function Se(e, n) {
|
|
|
1397
1402
|
);
|
|
1398
1403
|
continue;
|
|
1399
1404
|
}
|
|
1400
|
-
const
|
|
1401
|
-
t - a.publishTime >
|
|
1405
|
+
const c = a.expiration || 60;
|
|
1406
|
+
t - a.publishTime > c && (console.info(
|
|
1402
1407
|
`stale price feed, id: ${a.priceFeedId}, publish time: ${a.publishTime}, current timestamp: ${t}`
|
|
1403
1408
|
), o.push(a.priceFeedId));
|
|
1404
1409
|
}
|
|
@@ -1485,12 +1490,17 @@ async function ne(e) {
|
|
|
1485
1490
|
})).oracle.feeds;
|
|
1486
1491
|
}
|
|
1487
1492
|
function Ee(e, n) {
|
|
1488
|
-
return e.filter((o) => !!(n?.lendingState && n.lendingState.find((t) =>
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1493
|
+
return e.filter((o) => !!(n?.lendingState && n.lendingState.find((t) => o.oracleId === t.pool.oracleId) || n?.lendingPositions && n.lendingPositions.find((t) => {
|
|
1494
|
+
if (![
|
|
1495
|
+
"navi-lending-supply",
|
|
1496
|
+
"navi-lending-borrow",
|
|
1497
|
+
"navi-lending-emode-supply",
|
|
1498
|
+
"navi-lending-emode-borrow"
|
|
1499
|
+
].includes(t.type))
|
|
1500
|
+
return !1;
|
|
1501
|
+
const c = t[t.type]?.pool;
|
|
1502
|
+
return o.oracleId === c?.oracleId;
|
|
1503
|
+
}) || n?.pools && n.pools.find((t) => o.oracleId === t.oracleId)));
|
|
1494
1504
|
}
|
|
1495
1505
|
async function mt(e, n, o, r) {
|
|
1496
1506
|
try {
|
|
@@ -1500,11 +1510,11 @@ async function mt(e, n, o, r) {
|
|
|
1500
1510
|
o.forEach((u) => {
|
|
1501
1511
|
a.includes(u.market) || a.push(u.market);
|
|
1502
1512
|
});
|
|
1503
|
-
const
|
|
1513
|
+
const c = await $e(n, {
|
|
1504
1514
|
...r,
|
|
1505
1515
|
markets: a
|
|
1506
1516
|
}), i = Ee(t, {
|
|
1507
|
-
lendingPositions:
|
|
1517
|
+
lendingPositions: c,
|
|
1508
1518
|
pools: o
|
|
1509
1519
|
});
|
|
1510
1520
|
return await Me(e, i, {
|
|
@@ -1520,7 +1530,7 @@ async function mt(e, n, o, r) {
|
|
|
1520
1530
|
const G = $(
|
|
1521
1531
|
B(
|
|
1522
1532
|
async (e) => {
|
|
1523
|
-
const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market ||
|
|
1533
|
+
const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${V.version}&market=${e?.market || D}`, o = await fetch(n, { headers: M }).then((r) => r.json());
|
|
1524
1534
|
return Object.keys(o.data).map((r) => ({
|
|
1525
1535
|
...o.data[r],
|
|
1526
1536
|
coinType: r
|
|
@@ -1540,11 +1550,11 @@ async function yt(e, n, o, r) {
|
|
|
1540
1550
|
...r,
|
|
1541
1551
|
cacheTime: b
|
|
1542
1552
|
})).some(
|
|
1543
|
-
(
|
|
1553
|
+
(s) => k(s.coinType) === k(a.suiCoinType)
|
|
1544
1554
|
))
|
|
1545
1555
|
throw new Error("Pool does not support flashloan");
|
|
1546
1556
|
if (t.version === 1) {
|
|
1547
|
-
const [
|
|
1557
|
+
const [s, u] = e.moveCall({
|
|
1548
1558
|
target: `${t.package}::lending::flash_loan_with_ctx`,
|
|
1549
1559
|
arguments: [
|
|
1550
1560
|
e.object(t.flashloanConfig),
|
|
@@ -1553,9 +1563,9 @@ async function yt(e, n, o, r) {
|
|
|
1553
1563
|
],
|
|
1554
1564
|
typeArguments: [a.suiCoinType]
|
|
1555
1565
|
});
|
|
1556
|
-
return [
|
|
1566
|
+
return [s, u];
|
|
1557
1567
|
} else {
|
|
1558
|
-
const [
|
|
1568
|
+
const [s, u] = e.moveCall({
|
|
1559
1569
|
target: `${t.package}::lending::flash_loan_with_ctx_v2`,
|
|
1560
1570
|
arguments: [
|
|
1561
1571
|
e.object(t.flashloanConfig),
|
|
@@ -1565,19 +1575,19 @@ async function yt(e, n, o, r) {
|
|
|
1565
1575
|
],
|
|
1566
1576
|
typeArguments: [a.suiCoinType]
|
|
1567
1577
|
});
|
|
1568
|
-
return [
|
|
1578
|
+
return [s, u];
|
|
1569
1579
|
}
|
|
1570
1580
|
}
|
|
1571
1581
|
async function gt(e, n, o, r, t) {
|
|
1572
1582
|
const a = await _({
|
|
1573
1583
|
...t,
|
|
1574
1584
|
cacheTime: b
|
|
1575
|
-
}),
|
|
1585
|
+
}), c = await A(n, t);
|
|
1576
1586
|
if (!(await G({
|
|
1577
1587
|
...t,
|
|
1578
1588
|
cacheTime: b
|
|
1579
1589
|
})).some(
|
|
1580
|
-
(d) => k(d.coinType) === k(
|
|
1590
|
+
(d) => k(d.coinType) === k(c.suiCoinType)
|
|
1581
1591
|
))
|
|
1582
1592
|
throw new Error("Pool does not support flashloan");
|
|
1583
1593
|
const [u] = e.moveCall({
|
|
@@ -1585,19 +1595,19 @@ async function gt(e, n, o, r, t) {
|
|
|
1585
1595
|
arguments: [
|
|
1586
1596
|
e.object("0x06"),
|
|
1587
1597
|
e.object(a.storage),
|
|
1588
|
-
e.object(
|
|
1598
|
+
e.object(c.contract.pool),
|
|
1589
1599
|
h(o, e.object),
|
|
1590
1600
|
h(r, e.object)
|
|
1591
1601
|
],
|
|
1592
|
-
typeArguments: [
|
|
1602
|
+
typeArguments: [c.suiCoinType]
|
|
1593
1603
|
});
|
|
1594
1604
|
return [u];
|
|
1595
1605
|
}
|
|
1596
1606
|
async function ht(e, n, o, r, t, a) {
|
|
1597
|
-
const
|
|
1607
|
+
const c = {
|
|
1598
1608
|
...a,
|
|
1599
1609
|
cacheTime: b
|
|
1600
|
-
}, i = await _(
|
|
1610
|
+
}, i = await _(c), s = await A(n, c), u = await A(r, c);
|
|
1601
1611
|
if (i.version === 1) {
|
|
1602
1612
|
const [d, y] = e.moveCall({
|
|
1603
1613
|
target: `${i.package}::incentive_v3::liquidation`,
|
|
@@ -1608,9 +1618,9 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1608
1618
|
// Price oracle for asset pricing
|
|
1609
1619
|
e.object(i.storage),
|
|
1610
1620
|
// Protocol storage
|
|
1611
|
-
e.pure.u8(
|
|
1621
|
+
e.pure.u8(s.id),
|
|
1612
1622
|
// Pay asset ID
|
|
1613
|
-
e.object(
|
|
1623
|
+
e.object(s.contract.pool),
|
|
1614
1624
|
// Pay asset pool contract
|
|
1615
1625
|
h(o, e.object),
|
|
1616
1626
|
// Debt repayment amount
|
|
@@ -1625,7 +1635,7 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1625
1635
|
e.object(i.incentiveV3)
|
|
1626
1636
|
// Incentive V3 contract
|
|
1627
1637
|
],
|
|
1628
|
-
typeArguments: [
|
|
1638
|
+
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
1629
1639
|
});
|
|
1630
1640
|
return [d, y];
|
|
1631
1641
|
} else {
|
|
@@ -1638,9 +1648,9 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1638
1648
|
// Price oracle for asset pricing
|
|
1639
1649
|
e.object(i.storage),
|
|
1640
1650
|
// Protocol storage
|
|
1641
|
-
e.pure.u8(
|
|
1651
|
+
e.pure.u8(s.id),
|
|
1642
1652
|
// Pay asset ID
|
|
1643
|
-
e.object(
|
|
1653
|
+
e.object(s.contract.pool),
|
|
1644
1654
|
// Pay asset pool contract
|
|
1645
1655
|
h(o, e.object),
|
|
1646
1656
|
// Debt repayment amount
|
|
@@ -1657,17 +1667,17 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1657
1667
|
e.object("0x05")
|
|
1658
1668
|
// SuiSystemState object
|
|
1659
1669
|
],
|
|
1660
|
-
typeArguments: [
|
|
1670
|
+
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
1661
1671
|
});
|
|
1662
1672
|
return [d, y];
|
|
1663
1673
|
}
|
|
1664
1674
|
}
|
|
1665
1675
|
async function De(e, n, o) {
|
|
1666
|
-
const r = o?.client ?? P, t = new
|
|
1676
|
+
const r = o?.client ?? P, t = new N(), a = await R({
|
|
1667
1677
|
...o,
|
|
1668
1678
|
markets: Object.values(E),
|
|
1669
1679
|
cacheTime: b
|
|
1670
|
-
}),
|
|
1680
|
+
}), c = await ne(o);
|
|
1671
1681
|
for (let d of n) {
|
|
1672
1682
|
const y = await _({
|
|
1673
1683
|
...o,
|
|
@@ -1691,9 +1701,9 @@ async function De(e, n, o) {
|
|
|
1691
1701
|
const i = await r.devInspectTransactionBlock({
|
|
1692
1702
|
transactionBlock: t,
|
|
1693
1703
|
sender: e
|
|
1694
|
-
}),
|
|
1704
|
+
}), s = [];
|
|
1695
1705
|
i?.results?.forEach((d) => {
|
|
1696
|
-
|
|
1706
|
+
s.push(
|
|
1697
1707
|
L(
|
|
1698
1708
|
{
|
|
1699
1709
|
results: [d]
|
|
@@ -1714,15 +1724,15 @@ async function De(e, n, o) {
|
|
|
1714
1724
|
);
|
|
1715
1725
|
});
|
|
1716
1726
|
const u = [];
|
|
1717
|
-
return
|
|
1727
|
+
return s.forEach((d, y) => {
|
|
1718
1728
|
const v = n[y];
|
|
1719
1729
|
if (d.length === 5 && Array.isArray(d[0])) {
|
|
1720
1730
|
const g = d[0].length;
|
|
1721
1731
|
for (let l = 0; l < g; l++) {
|
|
1722
|
-
const f =
|
|
1723
|
-
(
|
|
1732
|
+
const f = c.find(
|
|
1733
|
+
(I) => k(I.coinType) === k(d[1][l])
|
|
1724
1734
|
), w = a.find(
|
|
1725
|
-
(
|
|
1735
|
+
(I) => k(I.coinType) === k(d[0][l]) && I.market === v.market
|
|
1726
1736
|
);
|
|
1727
1737
|
!f || !w || u.push({
|
|
1728
1738
|
assetId: w.id,
|
|
@@ -1753,12 +1763,12 @@ async function vt(e, n) {
|
|
|
1753
1763
|
owner: e,
|
|
1754
1764
|
market: a.key
|
|
1755
1765
|
})).concat(
|
|
1756
|
-
r.filter((a) => !!o.find((
|
|
1757
|
-
const
|
|
1766
|
+
r.filter((a) => !!o.find((c) => c.id === a.marketId)).map((a) => {
|
|
1767
|
+
const c = j(a.marketId);
|
|
1758
1768
|
return {
|
|
1759
1769
|
address: a.accountCap,
|
|
1760
1770
|
owner: e,
|
|
1761
|
-
market:
|
|
1771
|
+
market: c.key,
|
|
1762
1772
|
emodeId: a.emodeId
|
|
1763
1773
|
};
|
|
1764
1774
|
})
|
|
@@ -1768,8 +1778,8 @@ async function vt(e, n) {
|
|
|
1768
1778
|
function wt(e) {
|
|
1769
1779
|
const n = /* @__PURE__ */ new Map();
|
|
1770
1780
|
e.forEach((r) => {
|
|
1771
|
-
const t = r.assetId, a = r.option,
|
|
1772
|
-
n.has(
|
|
1781
|
+
const t = r.assetId, a = r.option, c = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
|
|
1782
|
+
n.has(c) ? n.get(c).total += r.userClaimableReward : n.set(c, {
|
|
1773
1783
|
assetId: t,
|
|
1774
1784
|
rewardType: a,
|
|
1775
1785
|
coinType: r.rewardCoinType,
|
|
@@ -1778,11 +1788,11 @@ function wt(e) {
|
|
|
1778
1788
|
});
|
|
1779
1789
|
});
|
|
1780
1790
|
const o = /* @__PURE__ */ new Map();
|
|
1781
|
-
for (const { assetId: r, rewardType: t, coinType: a, total:
|
|
1782
|
-
const
|
|
1783
|
-
o.has(
|
|
1784
|
-
const u = o.get(
|
|
1785
|
-
u.rewards.set(a, (u.rewards.get(a) || 0) +
|
|
1791
|
+
for (const { assetId: r, rewardType: t, coinType: a, total: c, market: i } of n.values()) {
|
|
1792
|
+
const s = `${r}-${t}-${i}`;
|
|
1793
|
+
o.has(s) || o.set(s, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
|
|
1794
|
+
const u = o.get(s);
|
|
1795
|
+
u.rewards.set(a, (u.rewards.get(a) || 0) + c);
|
|
1786
1796
|
}
|
|
1787
1797
|
return Array.from(o.values()).map((r) => ({
|
|
1788
1798
|
assetId: r.assetId,
|
|
@@ -1796,12 +1806,12 @@ function wt(e) {
|
|
|
1796
1806
|
}
|
|
1797
1807
|
const bt = B(
|
|
1798
1808
|
async (e, n) => {
|
|
1799
|
-
const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${n?.market ||
|
|
1809
|
+
const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${V.version}&market=${n?.market || D}`;
|
|
1800
1810
|
return (await fetch(o, { headers: M }).then((t) => t.json())).data;
|
|
1801
1811
|
}
|
|
1802
1812
|
), kt = B(
|
|
1803
1813
|
async (e, n) => {
|
|
1804
|
-
const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${n?.page || 1}&pageSize=${n?.size || 400}&sdk=${V.version}&market=${n?.market ||
|
|
1814
|
+
const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${n?.page || 1}&pageSize=${n?.size || 400}&sdk=${V.version}&market=${n?.market || D}`, r = await fetch(o, { headers: M }).then((t) => t.json());
|
|
1805
1815
|
return W({
|
|
1806
1816
|
data: r.data.rewards
|
|
1807
1817
|
});
|
|
@@ -1813,9 +1823,9 @@ async function _t(e, n, o) {
|
|
|
1813
1823
|
markets: Object.values(E),
|
|
1814
1824
|
cacheTime: b
|
|
1815
1825
|
}), t = /* @__PURE__ */ new Map();
|
|
1816
|
-
for (const
|
|
1817
|
-
const { rewardCoinType: i, ruleIds:
|
|
1818
|
-
for (const l of
|
|
1826
|
+
for (const c of n) {
|
|
1827
|
+
const { rewardCoinType: i, ruleIds: s, market: u, owner: d, address: y, emodeId: v } = c, g = `${i}___${y}`;
|
|
1828
|
+
for (const l of s) {
|
|
1819
1829
|
t.has(g) || t.set(g, {
|
|
1820
1830
|
assetIds: [],
|
|
1821
1831
|
ruleIds: [],
|
|
@@ -1826,24 +1836,24 @@ async function _t(e, n, o) {
|
|
|
1826
1836
|
isEMode: typeof v < "u"
|
|
1827
1837
|
});
|
|
1828
1838
|
const f = t.get(g);
|
|
1829
|
-
f.assetIds.push(
|
|
1839
|
+
f.assetIds.push(c.assetCoinType.replace("0x", "")), f.ruleIds.push(l), f.amount += c.userClaimableReward;
|
|
1830
1840
|
}
|
|
1831
1841
|
}
|
|
1832
1842
|
const a = [];
|
|
1833
1843
|
for (const [
|
|
1834
|
-
|
|
1835
|
-
{ assetIds: i, ruleIds:
|
|
1844
|
+
c,
|
|
1845
|
+
{ assetIds: i, ruleIds: s, amount: u, market: d, owner: y, address: v, isEMode: g }
|
|
1836
1846
|
] of t) {
|
|
1837
1847
|
const l = await _({
|
|
1838
1848
|
...o,
|
|
1839
1849
|
cacheTime: b,
|
|
1840
1850
|
market: d
|
|
1841
|
-
}), f =
|
|
1851
|
+
}), f = c.split("___")[0], w = r.find(
|
|
1842
1852
|
(S) => k(S.suiCoinType) === k(f) && S.market === d
|
|
1843
1853
|
);
|
|
1844
1854
|
if (!w || !w.contract.rewardFundId)
|
|
1845
1855
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${d}`);
|
|
1846
|
-
const
|
|
1856
|
+
const I = w.contract.rewardFundId;
|
|
1847
1857
|
if (o?.accountCap && !o.customCoinReceive)
|
|
1848
1858
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
1849
1859
|
if (o?.customCoinReceive) {
|
|
@@ -1857,11 +1867,11 @@ async function _t(e, n, o) {
|
|
|
1857
1867
|
// Incentive V3 contract
|
|
1858
1868
|
e.object(l.storage),
|
|
1859
1869
|
// Protocol storage
|
|
1860
|
-
e.object(
|
|
1870
|
+
e.object(I),
|
|
1861
1871
|
// Reward fund
|
|
1862
1872
|
e.pure.vector("string", i),
|
|
1863
1873
|
// Asset IDs
|
|
1864
|
-
e.pure.vector("address",
|
|
1874
|
+
e.pure.vector("address", s),
|
|
1865
1875
|
// Rule IDs
|
|
1866
1876
|
h(o.accountCap, e.object)
|
|
1867
1877
|
// Account capability
|
|
@@ -1876,11 +1886,11 @@ async function _t(e, n, o) {
|
|
|
1876
1886
|
// Incentive V3 contract
|
|
1877
1887
|
e.object(l.storage),
|
|
1878
1888
|
// Protocol storage
|
|
1879
|
-
e.object(
|
|
1889
|
+
e.object(I),
|
|
1880
1890
|
// Reward fund
|
|
1881
1891
|
e.pure.vector("string", i),
|
|
1882
1892
|
// Asset IDs
|
|
1883
|
-
e.pure.vector("address",
|
|
1893
|
+
e.pure.vector("address", s),
|
|
1884
1894
|
// Rule IDs
|
|
1885
1895
|
h(v, e.object)
|
|
1886
1896
|
// Account capability
|
|
@@ -1895,16 +1905,16 @@ async function _t(e, n, o) {
|
|
|
1895
1905
|
// Incentive V3 contract
|
|
1896
1906
|
e.object(l.storage),
|
|
1897
1907
|
// Protocol storage
|
|
1898
|
-
e.object(
|
|
1908
|
+
e.object(I),
|
|
1899
1909
|
// Reward fund
|
|
1900
1910
|
e.pure.vector("string", i),
|
|
1901
1911
|
// Asset IDs
|
|
1902
|
-
e.pure.vector("address",
|
|
1912
|
+
e.pure.vector("address", s)
|
|
1903
1913
|
// Rule IDs
|
|
1904
1914
|
],
|
|
1905
1915
|
typeArguments: [f]
|
|
1906
1916
|
});
|
|
1907
|
-
const [
|
|
1917
|
+
const [U] = e.moveCall({
|
|
1908
1918
|
target: "0x2::coin::from_balance",
|
|
1909
1919
|
arguments: [S],
|
|
1910
1920
|
typeArguments: [f]
|
|
@@ -1913,19 +1923,19 @@ async function _t(e, n, o) {
|
|
|
1913
1923
|
if (!o.customCoinReceive.transfer)
|
|
1914
1924
|
throw new Error("customCoinReceive.transfer is required");
|
|
1915
1925
|
e.transferObjects(
|
|
1916
|
-
[
|
|
1926
|
+
[U],
|
|
1917
1927
|
h(o.customCoinReceive.transfer, e.pure.address)
|
|
1918
1928
|
);
|
|
1919
1929
|
}
|
|
1920
1930
|
if (o?.customCoinReceive.type === "depositNAVI") {
|
|
1921
1931
|
const re = p(w.totalSupplyAmount).shiftedBy(-9), ae = p(w.supplyCapCeiling).shiftedBy(-27);
|
|
1922
1932
|
re.plus(u).isGreaterThan(ae) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
1923
|
-
[
|
|
1933
|
+
[U],
|
|
1924
1934
|
e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
1925
|
-
) : await _e(e, w,
|
|
1935
|
+
) : await _e(e, w, U, o);
|
|
1926
1936
|
} else
|
|
1927
1937
|
a.push({
|
|
1928
|
-
coin:
|
|
1938
|
+
coin: U,
|
|
1929
1939
|
identifier: w,
|
|
1930
1940
|
owner: y,
|
|
1931
1941
|
isEMode: g
|
|
@@ -1940,23 +1950,23 @@ async function _t(e, n, o) {
|
|
|
1940
1950
|
// Incentive V3 contract
|
|
1941
1951
|
e.object(l.storage),
|
|
1942
1952
|
// Protocol storage
|
|
1943
|
-
e.object(
|
|
1953
|
+
e.object(I),
|
|
1944
1954
|
// Reward fund
|
|
1945
1955
|
e.pure.vector("string", i),
|
|
1946
1956
|
// Asset IDs
|
|
1947
|
-
e.pure.vector("address",
|
|
1957
|
+
e.pure.vector("address", s),
|
|
1948
1958
|
// Rule IDs
|
|
1949
1959
|
h(o?.accountCap || v, e.object)
|
|
1950
1960
|
// Account capability
|
|
1951
1961
|
],
|
|
1952
1962
|
typeArguments: [f]
|
|
1953
|
-
}), [
|
|
1963
|
+
}), [U] = e.moveCall({
|
|
1954
1964
|
target: "0x2::coin::from_balance",
|
|
1955
1965
|
arguments: [S],
|
|
1956
1966
|
typeArguments: [f]
|
|
1957
1967
|
});
|
|
1958
1968
|
e.transferObjects(
|
|
1959
|
-
[
|
|
1969
|
+
[U],
|
|
1960
1970
|
h(o?.accountCap || y, e.pure.address)
|
|
1961
1971
|
);
|
|
1962
1972
|
} else
|
|
@@ -1969,11 +1979,11 @@ async function _t(e, n, o) {
|
|
|
1969
1979
|
// Incentive V3 contract
|
|
1970
1980
|
e.object(l.storage),
|
|
1971
1981
|
// Protocol storage
|
|
1972
|
-
e.object(
|
|
1982
|
+
e.object(I),
|
|
1973
1983
|
// Reward fund
|
|
1974
1984
|
e.pure.vector("string", i),
|
|
1975
1985
|
// Asset IDs
|
|
1976
|
-
e.pure.vector("address",
|
|
1986
|
+
e.pure.vector("address", s)
|
|
1977
1987
|
// Rule IDs
|
|
1978
1988
|
],
|
|
1979
1989
|
typeArguments: [f]
|
|
@@ -1984,7 +1994,7 @@ async function _t(e, n, o) {
|
|
|
1984
1994
|
export {
|
|
1985
1995
|
z as Address,
|
|
1986
1996
|
b as DEFAULT_CACHE_TIME,
|
|
1987
|
-
|
|
1997
|
+
D as DEFAULT_MARKET_IDENTITY,
|
|
1988
1998
|
Ke as FlashLoanAssetConfig,
|
|
1989
1999
|
He as IncentiveAPYInfo,
|
|
1990
2000
|
me as IncentivePoolInfo,
|
|
@@ -1994,11 +2004,11 @@ export {
|
|
|
1994
2004
|
ze as OracleInfo,
|
|
1995
2005
|
F as PoolOperator,
|
|
1996
2006
|
Ye as ReserveDataInfo,
|
|
1997
|
-
|
|
2007
|
+
O as UserPositions,
|
|
1998
2008
|
fe as UserStateInfo,
|
|
1999
2009
|
Xe as borrowCoinPTB,
|
|
2000
2010
|
_t as claimLendingRewardsPTB,
|
|
2001
|
-
|
|
2011
|
+
Ie as createAccountCapPTB,
|
|
2002
2012
|
nt as createEModeCapPTB,
|
|
2003
2013
|
_e as depositCoinPTB,
|
|
2004
2014
|
rt as emodeIdentityId,
|
|
@@ -2006,7 +2016,7 @@ export {
|
|
|
2006
2016
|
ot as exitEModePTB,
|
|
2007
2017
|
Ee as filterPriceFeeds,
|
|
2008
2018
|
yt as flashloanPTB,
|
|
2009
|
-
|
|
2019
|
+
Te as getAccountCapOwnerPTB,
|
|
2010
2020
|
G as getAllFlashLoanAssets,
|
|
2011
2021
|
et as getBorrowFee,
|
|
2012
2022
|
lt as getCoins,
|