@naviprotocol/lending 1.4.2-beta.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +156 -158
- package/dist/index.esm.js.map +1 -1
- package/dist/reward.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import { SuiClient as se, getFullnodeUrl as
|
|
4
|
-
import
|
|
3
|
+
import { SuiClient as se, getFullnodeUrl as le } from "@mysten/sui/client";
|
|
4
|
+
import ue from "lodash.camelcase";
|
|
5
5
|
import { normalizeStructTag as pe } from "@mysten/sui/utils";
|
|
6
6
|
import { SuiPriceServiceConnection as Z, SuiPythClient as de } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import p from "bignumber.js";
|
|
@@ -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.
|
|
132
|
+
}), ye = "1.4.3", S = {
|
|
133
133
|
version: ye
|
|
134
134
|
}, ge = S.version, he = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node)
|
|
@@ -143,8 +143,8 @@ const z = m.bytes(32).transform({
|
|
|
143
143
|
}, ve = () => {
|
|
144
144
|
let e = "";
|
|
145
145
|
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ge} (${he()})`), e;
|
|
146
|
-
}, K = ve(),
|
|
147
|
-
url:
|
|
146
|
+
}, K = ve(), $ = new se({
|
|
147
|
+
url: le("mainnet")
|
|
148
148
|
});
|
|
149
149
|
function Q(e) {
|
|
150
150
|
const n = [];
|
|
@@ -166,11 +166,11 @@ function B(e) {
|
|
|
166
166
|
})), n[r];
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function P(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((c) => (n[t] = {
|
|
173
|
+
return !r?.disableCache && typeof a?.data < "u" && (typeof r?.cacheTime > "u" || r.cacheTime > Date.now() - a.cacheAt) ? Promise.resolve(a.data) : e(...o).then((c) => (n[t] = {
|
|
174
174
|
data: c,
|
|
175
175
|
cacheAt: Date.now()
|
|
176
176
|
}, c));
|
|
@@ -180,7 +180,7 @@ function W(e) {
|
|
|
180
180
|
return Array.isArray(e) ? e.map((n) => W(n)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
181
181
|
(n, o) => ({
|
|
182
182
|
...n,
|
|
183
|
-
[
|
|
183
|
+
[ue(o)]: W(e[o])
|
|
184
184
|
}),
|
|
185
185
|
{}
|
|
186
186
|
) : e;
|
|
@@ -253,7 +253,7 @@ 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 || {});
|
|
256
|
-
const R =
|
|
256
|
+
const R = P(
|
|
257
257
|
B(
|
|
258
258
|
async (e) => {
|
|
259
259
|
const n = (e?.markets || [E.main]).map((t) => j(t)), o = `https://open-api.naviprotocol.io/api/navi/pools?env=${e?.env || "prod"}&sdk=${S.version}&market=${n.map(
|
|
@@ -265,11 +265,11 @@ const R = $(
|
|
|
265
265
|
return t.market === w.key && f.isActive;
|
|
266
266
|
}).filter((f) => !!f.assets.find((w) => w.assetId === t.id));
|
|
267
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(),
|
|
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(), l = 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
|
-
).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), g = p(y).multipliedBy(t.oracle.price).toString(),
|
|
272
|
-
t.poolSupplyAmount = i, t.poolBorrowAmount = s, t.poolSupplyValue =
|
|
271
|
+
).shiftedBy(-9).decimalPlaces(t.token.decimals, p.ROUND_DOWN).toString(), g = p(y).multipliedBy(t.oracle.price).toString(), u = p(v).multipliedBy(t.oracle.price).toString();
|
|
272
|
+
t.poolSupplyAmount = i, t.poolBorrowAmount = s, t.poolSupplyValue = l, t.poolBorrowValue = d, t.poolSupplyCapAmount = y, t.poolBorrowCapAmount = v, t.poolSupplyCapValue = g, t.poolBorrowCapValue = u;
|
|
273
273
|
}), r.data;
|
|
274
274
|
}
|
|
275
275
|
)
|
|
@@ -292,12 +292,12 @@ async function A(e, n) {
|
|
|
292
292
|
throw new Error("Pool not found");
|
|
293
293
|
return t.isDeprecated && console.log(`The lending pool for coinType ${t.suiCoinType} is going to be deprecated.`), t;
|
|
294
294
|
}
|
|
295
|
-
const Je =
|
|
295
|
+
const Je = P(
|
|
296
296
|
B(async (e) => {
|
|
297
297
|
const n = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${S.version}`;
|
|
298
298
|
return (await fetch(n, { headers: M }).then((r) => r.json())).data;
|
|
299
299
|
})
|
|
300
|
-
), Ze =
|
|
300
|
+
), Ze = P(
|
|
301
301
|
B(
|
|
302
302
|
async (e) => {
|
|
303
303
|
const n = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${S.version}`;
|
|
@@ -362,7 +362,7 @@ async function Qe(e, n, o, r) {
|
|
|
362
362
|
let i;
|
|
363
363
|
if (t.version === 1)
|
|
364
364
|
if (r?.accountCap) {
|
|
365
|
-
const [
|
|
365
|
+
const [l] = e.moveCall({
|
|
366
366
|
target: `${t.package}::incentive_v3::withdraw_with_account_cap`,
|
|
367
367
|
arguments: [
|
|
368
368
|
e.object("0x06"),
|
|
@@ -377,9 +377,9 @@ async function Qe(e, n, o, r) {
|
|
|
377
377
|
],
|
|
378
378
|
typeArguments: [a.suiCoinType]
|
|
379
379
|
});
|
|
380
|
-
i =
|
|
380
|
+
i = l;
|
|
381
381
|
} else {
|
|
382
|
-
const [
|
|
382
|
+
const [l] = e.moveCall({
|
|
383
383
|
target: `${t.package}::incentive_v3::withdraw`,
|
|
384
384
|
arguments: [
|
|
385
385
|
e.object("0x06"),
|
|
@@ -393,10 +393,10 @@ async function Qe(e, n, o, r) {
|
|
|
393
393
|
],
|
|
394
394
|
typeArguments: [a.suiCoinType]
|
|
395
395
|
});
|
|
396
|
-
i =
|
|
396
|
+
i = l;
|
|
397
397
|
}
|
|
398
398
|
else if (r?.accountCap) {
|
|
399
|
-
const [
|
|
399
|
+
const [l] = e.moveCall({
|
|
400
400
|
target: `${t.package}::incentive_v3::withdraw_with_account_cap_v2`,
|
|
401
401
|
arguments: [
|
|
402
402
|
e.object("0x06"),
|
|
@@ -412,9 +412,9 @@ async function Qe(e, n, o, r) {
|
|
|
412
412
|
],
|
|
413
413
|
typeArguments: [a.suiCoinType]
|
|
414
414
|
});
|
|
415
|
-
i =
|
|
415
|
+
i = l;
|
|
416
416
|
} else {
|
|
417
|
-
const [
|
|
417
|
+
const [l] = e.moveCall({
|
|
418
418
|
target: `${t.package}::incentive_v3::withdraw_v2`,
|
|
419
419
|
arguments: [
|
|
420
420
|
e.object("0x06"),
|
|
@@ -429,7 +429,7 @@ async function Qe(e, n, o, r) {
|
|
|
429
429
|
],
|
|
430
430
|
typeArguments: [a.suiCoinType]
|
|
431
431
|
});
|
|
432
|
-
i =
|
|
432
|
+
i = l;
|
|
433
433
|
}
|
|
434
434
|
return e.moveCall({
|
|
435
435
|
target: "0x2::coin::from_balance",
|
|
@@ -448,7 +448,7 @@ async function Xe(e, n, o, r) {
|
|
|
448
448
|
let i;
|
|
449
449
|
if (t.version === 1)
|
|
450
450
|
if (r?.accountCap) {
|
|
451
|
-
const [
|
|
451
|
+
const [l] = e.moveCall({
|
|
452
452
|
target: `${t.package}::incentive_v3::borrow_with_account_cap`,
|
|
453
453
|
arguments: [
|
|
454
454
|
e.object("0x06"),
|
|
@@ -463,9 +463,9 @@ async function Xe(e, n, o, r) {
|
|
|
463
463
|
],
|
|
464
464
|
typeArguments: [a.suiCoinType]
|
|
465
465
|
});
|
|
466
|
-
i =
|
|
466
|
+
i = l;
|
|
467
467
|
} else {
|
|
468
|
-
const [
|
|
468
|
+
const [l] = e.moveCall({
|
|
469
469
|
target: `${t.package}::incentive_v3::borrow`,
|
|
470
470
|
arguments: [
|
|
471
471
|
e.object("0x06"),
|
|
@@ -479,10 +479,10 @@ async function Xe(e, n, o, r) {
|
|
|
479
479
|
],
|
|
480
480
|
typeArguments: [a.suiCoinType]
|
|
481
481
|
});
|
|
482
|
-
i =
|
|
482
|
+
i = l;
|
|
483
483
|
}
|
|
484
484
|
else if (r?.accountCap) {
|
|
485
|
-
const [
|
|
485
|
+
const [l] = e.moveCall({
|
|
486
486
|
target: `${t.package}::incentive_v3::borrow_with_account_cap_v2`,
|
|
487
487
|
arguments: [
|
|
488
488
|
e.object("0x06"),
|
|
@@ -498,9 +498,9 @@ async function Xe(e, n, o, r) {
|
|
|
498
498
|
],
|
|
499
499
|
typeArguments: [a.suiCoinType]
|
|
500
500
|
});
|
|
501
|
-
i =
|
|
501
|
+
i = l;
|
|
502
502
|
} else {
|
|
503
|
-
const [
|
|
503
|
+
const [l] = e.moveCall({
|
|
504
504
|
target: `${t.package}::incentive_v3::borrow_v2`,
|
|
505
505
|
arguments: [
|
|
506
506
|
e.object("0x06"),
|
|
@@ -515,7 +515,7 @@ async function Xe(e, n, o, r) {
|
|
|
515
515
|
],
|
|
516
516
|
typeArguments: [a.suiCoinType]
|
|
517
517
|
});
|
|
518
|
-
i =
|
|
518
|
+
i = l;
|
|
519
519
|
}
|
|
520
520
|
return e.moveCall({
|
|
521
521
|
target: "0x2::coin::from_balance",
|
|
@@ -576,7 +576,7 @@ async function xe(e, n, o, r) {
|
|
|
576
576
|
typeArguments: [a.suiCoinType]
|
|
577
577
|
}), e;
|
|
578
578
|
}
|
|
579
|
-
const et =
|
|
579
|
+
const et = P(
|
|
580
580
|
B(
|
|
581
581
|
async (e) => {
|
|
582
582
|
const n = await _({
|
|
@@ -584,7 +584,7 @@ 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 ??
|
|
587
|
+
const t = await A(e.asset, e), a = e?.client ?? $, c = new N();
|
|
588
588
|
c.moveCall({
|
|
589
589
|
target: `${n.package}::incentive_v3::get_borrow_fee_v2`,
|
|
590
590
|
arguments: [
|
|
@@ -603,7 +603,7 @@ const et = $(
|
|
|
603
603
|
} catch (t) {
|
|
604
604
|
console.error(t);
|
|
605
605
|
}
|
|
606
|
-
const r = (await
|
|
606
|
+
const r = (await $.getObject({
|
|
607
607
|
id: n.incentiveV3,
|
|
608
608
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
609
609
|
})).data.content.fields.borrow_fee_rate;
|
|
@@ -648,8 +648,8 @@ class Ce {
|
|
|
648
648
|
});
|
|
649
649
|
}), i = i.plus(s.poolBorrowValue), c = c.plus(s.poolSupplyValue);
|
|
650
650
|
}), this.poolMap = H(this.pools, "id"), this.emodeMap = J(this.emodes, "emodeId"), this.emodes.forEach((s) => {
|
|
651
|
-
const
|
|
652
|
-
this.emodePools.push(...
|
|
651
|
+
const l = this.getEModePools(s.emodeId);
|
|
652
|
+
this.emodePools.push(...l);
|
|
653
653
|
}), this._overview = {
|
|
654
654
|
marketTotalSupplyValue: c.toString(),
|
|
655
655
|
marketTotalBorrowValue: i.toString()
|
|
@@ -690,7 +690,7 @@ const j = (e) => {
|
|
|
690
690
|
if (!o)
|
|
691
691
|
throw new Error("Market not found");
|
|
692
692
|
return o;
|
|
693
|
-
}, je =
|
|
693
|
+
}, je = P(
|
|
694
694
|
B(
|
|
695
695
|
async (e, n) => {
|
|
696
696
|
const o = await R({
|
|
@@ -704,11 +704,11 @@ const j = (e) => {
|
|
|
704
704
|
});
|
|
705
705
|
}
|
|
706
706
|
)
|
|
707
|
-
), tt =
|
|
707
|
+
), tt = P(
|
|
708
708
|
B(
|
|
709
709
|
async (e, n) => (await je([e], n))[0]
|
|
710
710
|
)
|
|
711
|
-
), _ =
|
|
711
|
+
), _ = P(
|
|
712
712
|
B(
|
|
713
713
|
async (e) => {
|
|
714
714
|
const n = j(e?.market || D), o = `https://open-api.naviprotocol.io/api/navi/config?env=${e?.env || "prod"}&sdk=${S.version}&market=${n.key}`;
|
|
@@ -786,13 +786,13 @@ async function nt(e, n, o) {
|
|
|
786
786
|
]
|
|
787
787
|
}), t;
|
|
788
788
|
}
|
|
789
|
-
const x =
|
|
789
|
+
const x = P(
|
|
790
790
|
B(
|
|
791
791
|
async (e, n) => {
|
|
792
792
|
const o = await _({
|
|
793
793
|
cacheTime: b,
|
|
794
794
|
...n
|
|
795
|
-
}), r = new N(), t = n?.client ??
|
|
795
|
+
}), r = new N(), t = n?.client ?? $;
|
|
796
796
|
r.moveCall({
|
|
797
797
|
target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
798
798
|
arguments: [r.object(o.emode.contract.registryObject), r.pure.address(e)]
|
|
@@ -800,11 +800,11 @@ const x = $(
|
|
|
800
800
|
const c = (await t.devInspectTransactionBlock({
|
|
801
801
|
transactionBlock: r,
|
|
802
802
|
sender: e
|
|
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])),
|
|
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])), l = C.vector(C.Address).parse(Uint8Array.from(c[2][0]));
|
|
804
804
|
return i.map((d, y) => ({
|
|
805
805
|
marketId: Number(d),
|
|
806
806
|
emodeId: Number(s[y]),
|
|
807
|
-
accountCap:
|
|
807
|
+
accountCap: l[y].toString()
|
|
808
808
|
}));
|
|
809
809
|
}
|
|
810
810
|
)
|
|
@@ -817,7 +817,7 @@ function at(e, n, o) {
|
|
|
817
817
|
let a = 0;
|
|
818
818
|
const c = [];
|
|
819
819
|
let i = "";
|
|
820
|
-
if (n.sort((s,
|
|
820
|
+
if (n.sort((s, l) => Number(l.balance) - Number(s.balance)).forEach((s) => {
|
|
821
821
|
if (!(r && a >= t) && Number(s.balance) !== 0) {
|
|
822
822
|
if (i || (i = s.coinType), i !== s.coinType)
|
|
823
823
|
throw new Error("All coins must be of the same type");
|
|
@@ -856,7 +856,7 @@ async function Ae(e, n, o) {
|
|
|
856
856
|
return ee(e, n, 0, 0, 0, !1, o);
|
|
857
857
|
}
|
|
858
858
|
async function te(e, n, o) {
|
|
859
|
-
const r = new N(), t = o?.client ??
|
|
859
|
+
const r = new N(), t = o?.client ?? $, a = await R({
|
|
860
860
|
...o,
|
|
861
861
|
markets: Object.values(E)
|
|
862
862
|
}), c = H(a);
|
|
@@ -874,34 +874,34 @@ async function te(e, n, o) {
|
|
|
874
874
|
const s = ((await t.devInspectTransactionBlock({
|
|
875
875
|
transactionBlock: r,
|
|
876
876
|
sender: e
|
|
877
|
-
})).results || []).map((d) => d.returnValues?.map((y) => C.vector(fe).parse(Uint8Array.from(y[0])))[0] || []),
|
|
877
|
+
})).results || []).map((d) => d.returnValues?.map((y) => C.vector(fe).parse(Uint8Array.from(y[0])))[0] || []), l = [];
|
|
878
878
|
return s.forEach((d, y) => {
|
|
879
879
|
const v = n[y], g = j(v.market);
|
|
880
|
-
d.forEach((
|
|
881
|
-
if (
|
|
880
|
+
d.forEach((u) => {
|
|
881
|
+
if (u.supply_balance === "0" && u.borrow_balance === "0" && (v.emodeId === void 0 || !o?.includeZeroBalanceEmodePositions))
|
|
882
882
|
return;
|
|
883
|
-
const f = c[`${g.key}-${
|
|
883
|
+
const f = c[`${g.key}-${u.asset_id}`];
|
|
884
884
|
if (!f)
|
|
885
885
|
return;
|
|
886
886
|
const w = Y(
|
|
887
|
-
|
|
887
|
+
u.supply_balance,
|
|
888
888
|
f.currentSupplyIndex
|
|
889
889
|
).toString(), I = Y(
|
|
890
|
-
|
|
890
|
+
u.borrow_balance,
|
|
891
891
|
f.currentBorrowIndex
|
|
892
892
|
).toString();
|
|
893
|
-
|
|
893
|
+
l.push({
|
|
894
894
|
supplyBalance: w,
|
|
895
895
|
borrowBalance: I,
|
|
896
|
-
assetId:
|
|
896
|
+
assetId: u.asset_id,
|
|
897
897
|
market: g.key,
|
|
898
898
|
pool: f,
|
|
899
899
|
emodeId: v.emodeId
|
|
900
900
|
});
|
|
901
901
|
});
|
|
902
|
-
}),
|
|
902
|
+
}), l;
|
|
903
903
|
}
|
|
904
|
-
const it =
|
|
904
|
+
const it = P(
|
|
905
905
|
async (e, n) => {
|
|
906
906
|
const r = (n?.markets || Object.keys(E)).map((t) => j(t)).map((t) => ({
|
|
907
907
|
address: e,
|
|
@@ -911,7 +911,7 @@ const it = $(
|
|
|
911
911
|
}
|
|
912
912
|
);
|
|
913
913
|
async function ct(e, n) {
|
|
914
|
-
const o = n?.client ??
|
|
914
|
+
const o = n?.client ?? $, r = new N();
|
|
915
915
|
await Ae(r, e, n);
|
|
916
916
|
const t = await o.devInspectTransactionBlock({
|
|
917
917
|
transactionBlock: r,
|
|
@@ -920,21 +920,21 @@ async function ct(e, n) {
|
|
|
920
920
|
return X(Number(a[0]) || 0);
|
|
921
921
|
}
|
|
922
922
|
async function st(e, n, o, r) {
|
|
923
|
-
const t = r?.client ??
|
|
923
|
+
const t = r?.client ?? $, a = new N();
|
|
924
924
|
let c = 0, i = 0;
|
|
925
925
|
const s = await A(n, r);
|
|
926
926
|
if (o.forEach((v) => {
|
|
927
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
928
|
}), c * i < 0)
|
|
929
929
|
throw new Error("Invalid operations");
|
|
930
|
-
const
|
|
930
|
+
const l = c > 0 || i > 0;
|
|
931
931
|
await ee(
|
|
932
932
|
a,
|
|
933
933
|
e,
|
|
934
934
|
s,
|
|
935
935
|
Math.abs(c),
|
|
936
936
|
Math.abs(i),
|
|
937
|
-
|
|
937
|
+
l,
|
|
938
938
|
r
|
|
939
939
|
);
|
|
940
940
|
const d = await t.devInspectTransactionBlock({
|
|
@@ -943,7 +943,7 @@ async function st(e, n, o, r) {
|
|
|
943
943
|
}), y = L(d, [C.u256()]);
|
|
944
944
|
return X(Number(y[0]) || 0);
|
|
945
945
|
}
|
|
946
|
-
const
|
|
946
|
+
const lt = B(
|
|
947
947
|
async (e, n) => {
|
|
948
948
|
const o = new URLSearchParams();
|
|
949
949
|
n?.cursor && o.set("cursor", n.cursor), o.set("userAddress", e);
|
|
@@ -951,9 +951,9 @@ const ut = B(
|
|
|
951
951
|
return (await fetch(r, { headers: M }).then((a) => a.json())).data;
|
|
952
952
|
}
|
|
953
953
|
);
|
|
954
|
-
async function
|
|
954
|
+
async function ut(e, n) {
|
|
955
955
|
let o = null;
|
|
956
|
-
const r = [], t = n?.client ??
|
|
956
|
+
const r = [], t = n?.client ?? $;
|
|
957
957
|
do {
|
|
958
958
|
let a;
|
|
959
959
|
if (n?.coinType ? a = await t.getCoins({
|
|
@@ -971,7 +971,7 @@ async function lt(e, n) {
|
|
|
971
971
|
} while (o);
|
|
972
972
|
return r;
|
|
973
973
|
}
|
|
974
|
-
const
|
|
974
|
+
const Pe = P(
|
|
975
975
|
async (e, n) => {
|
|
976
976
|
const o = [], r = (n?.markets || Object.keys(E)).map((i) => j(i));
|
|
977
977
|
let t = [];
|
|
@@ -991,9 +991,9 @@ const $e = $(
|
|
|
991
991
|
}))
|
|
992
992
|
);
|
|
993
993
|
return (await te(e, a, n)).forEach((i) => {
|
|
994
|
-
const s = typeof i.emodeId == "number" ? t.find((
|
|
994
|
+
const s = typeof i.emodeId == "number" ? t.find((l) => {
|
|
995
995
|
const d = j(i.market);
|
|
996
|
-
return
|
|
996
|
+
return l.emodeId === i.emodeId && l.marketId === d.id;
|
|
997
997
|
}) : void 0;
|
|
998
998
|
if (s) {
|
|
999
999
|
if (!i.pool.emodes.find((d) => d.emodeId === s.emodeId))
|
|
@@ -1044,7 +1044,7 @@ const $e = $(
|
|
|
1044
1044
|
}
|
|
1045
1045
|
} else {
|
|
1046
1046
|
if (p(i.supplyBalance).gt(0)) {
|
|
1047
|
-
const
|
|
1047
|
+
const l = p(i.supplyBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1048
1048
|
o.push({
|
|
1049
1049
|
id: `${i.pool.uniqueId}_navi-lending-supply-${T()}`,
|
|
1050
1050
|
wallet: e,
|
|
@@ -1052,15 +1052,15 @@ const $e = $(
|
|
|
1052
1052
|
type: "navi-lending-supply",
|
|
1053
1053
|
market: i.market,
|
|
1054
1054
|
"navi-lending-supply": {
|
|
1055
|
-
amount:
|
|
1055
|
+
amount: l.toString(),
|
|
1056
1056
|
pool: i.pool,
|
|
1057
1057
|
token: i.pool.token,
|
|
1058
|
-
valueUSD:
|
|
1058
|
+
valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
|
|
1059
1059
|
}
|
|
1060
1060
|
});
|
|
1061
1061
|
}
|
|
1062
1062
|
if (p(i.borrowBalance).gt(0)) {
|
|
1063
|
-
const
|
|
1063
|
+
const l = p(i.borrowBalance).shiftedBy(-9).decimalPlaces(i.pool.token.decimals, p.ROUND_DOWN);
|
|
1064
1064
|
o.push({
|
|
1065
1065
|
id: `${i.pool.uniqueId}_navi-lending-borrow-${T()}`,
|
|
1066
1066
|
wallet: e,
|
|
@@ -1068,10 +1068,10 @@ const $e = $(
|
|
|
1068
1068
|
market: i.market,
|
|
1069
1069
|
type: "navi-lending-borrow",
|
|
1070
1070
|
"navi-lending-borrow": {
|
|
1071
|
-
amount:
|
|
1071
|
+
amount: l.toString(),
|
|
1072
1072
|
pool: i.pool,
|
|
1073
1073
|
token: i.pool.token,
|
|
1074
|
-
valueUSD:
|
|
1074
|
+
valueUSD: l.multipliedBy(i.pool.oracle.price).toString()
|
|
1075
1075
|
}
|
|
1076
1076
|
});
|
|
1077
1077
|
}
|
|
@@ -1252,52 +1252,52 @@ class O {
|
|
|
1252
1252
|
}
|
|
1253
1253
|
getPositionsOverview(n) {
|
|
1254
1254
|
const o = {}, r = {};
|
|
1255
|
-
let t = new p(0), a = new p(0), c = new p(0), i = new p(0), s = 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), l = new p(0);
|
|
1256
1256
|
n.forEach((g) => {
|
|
1257
1257
|
if (g.type === "navi-lending-supply") {
|
|
1258
|
-
const
|
|
1258
|
+
const u = g["navi-lending-supply"], f = this.resolveValueUSD(u);
|
|
1259
1259
|
t = t.plus(f), s = s.plus(
|
|
1260
|
-
new p(f).multipliedBy(
|
|
1261
|
-
),
|
|
1262
|
-
new p(f).multipliedBy(
|
|
1260
|
+
new p(f).multipliedBy(u.pool.liquidationFactor.threshold)
|
|
1261
|
+
), l = l.plus(
|
|
1262
|
+
new p(f).multipliedBy(u.pool.ltvValue)
|
|
1263
1263
|
);
|
|
1264
1264
|
} else if (g.type === "navi-lending-borrow") {
|
|
1265
|
-
const
|
|
1266
|
-
a = a.plus(this.resolveValueUSD(
|
|
1265
|
+
const u = g["navi-lending-borrow"];
|
|
1266
|
+
a = a.plus(this.resolveValueUSD(u));
|
|
1267
1267
|
} else if (g.type === "navi-lending-emode-supply") {
|
|
1268
|
-
const
|
|
1268
|
+
const u = g["navi-lending-emode-supply"], f = this.resolveValueUSD(u);
|
|
1269
1269
|
t = t.plus(f);
|
|
1270
|
-
const w =
|
|
1270
|
+
const w = u.pool.emode;
|
|
1271
1271
|
s = s.plus(
|
|
1272
1272
|
new p(f).multipliedBy(w.lt)
|
|
1273
|
-
),
|
|
1273
|
+
), l = l.plus(
|
|
1274
1274
|
new p(f).multipliedBy(w.ltv)
|
|
1275
1275
|
);
|
|
1276
1276
|
} else if (g.type === "navi-lending-emode-borrow") {
|
|
1277
|
-
const
|
|
1278
|
-
a = a.plus(this.resolveValueUSD(
|
|
1277
|
+
const u = g["navi-lending-emode-borrow"];
|
|
1278
|
+
a = a.plus(this.resolveValueUSD(u));
|
|
1279
1279
|
}
|
|
1280
|
-
}), a = p.max(a, 0), t = p.max(t, 0), s = p.max(s, 0),
|
|
1280
|
+
}), a = p.max(a, 0), t = p.max(t, 0), s = p.max(s, 0), l = p.max(l, 0), n.forEach((g) => {
|
|
1281
1281
|
if (g.type === "navi-lending-supply") {
|
|
1282
|
-
const
|
|
1282
|
+
const u = g["navi-lending-supply"], f = this.resolveValueUSD(u), w = u.pool.supplyIncentiveApyInfo.apy;
|
|
1283
1283
|
t.gt(0) && (c = c.plus(
|
|
1284
1284
|
new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
|
|
1285
|
-
)), o[
|
|
1285
|
+
)), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
|
|
1286
1286
|
} else if (g.type === "navi-lending-borrow") {
|
|
1287
|
-
const
|
|
1287
|
+
const u = g["navi-lending-borrow"], f = this.resolveValueUSD(u), w = u.pool.borrowIncentiveApyInfo.apy;
|
|
1288
1288
|
a.gt(0) && (i = i.plus(
|
|
1289
1289
|
new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
|
|
1290
|
-
)), r[
|
|
1290
|
+
)), r[u.pool.suiCoinType] = p(r[u.pool.suiCoinType] || 0).plus(u.amount).toString();
|
|
1291
1291
|
} else if (g.type === "navi-lending-emode-supply") {
|
|
1292
|
-
const
|
|
1292
|
+
const u = g["navi-lending-emode-supply"], f = this.resolveValueUSD(u), w = u.pool.supplyIncentiveApyInfo.apy;
|
|
1293
1293
|
t.gt(0) && (c = c.plus(
|
|
1294
1294
|
new p(f).dividedBy(t).multipliedBy(new p(w).dividedBy(100))
|
|
1295
|
-
)), o[
|
|
1295
|
+
)), o[u.pool.suiCoinType] = p(o[u.pool.suiCoinType] || 0).plus(u.amount).toString();
|
|
1296
1296
|
} else if (g.type === "navi-lending-emode-borrow") {
|
|
1297
|
-
const
|
|
1297
|
+
const u = g["navi-lending-emode-borrow"], f = this.resolveValueUSD(u), w = u.pool.borrowIncentiveApyInfo.apy;
|
|
1298
1298
|
a.gt(0) && (i = i.plus(
|
|
1299
1299
|
new p(f).dividedBy(a).multipliedBy(new p(w).dividedBy(100))
|
|
1300
|
-
)), r[
|
|
1300
|
+
)), r[u.pool.suiCoinType] = p(r[u.pool.suiCoinType] || 0).plus(u.amount).toString();
|
|
1301
1301
|
}
|
|
1302
1302
|
});
|
|
1303
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));
|
|
@@ -1310,7 +1310,7 @@ class O {
|
|
|
1310
1310
|
totalsupplyApy: c.toString(),
|
|
1311
1311
|
totalBorrowApy: i.toString(),
|
|
1312
1312
|
maxLiquidationValue: s.toString(),
|
|
1313
|
-
maxLoanToVaule:
|
|
1313
|
+
maxLoanToVaule: l.toString(),
|
|
1314
1314
|
supply: o,
|
|
1315
1315
|
borrow: r
|
|
1316
1316
|
};
|
|
@@ -1357,9 +1357,9 @@ async function dt(e) {
|
|
|
1357
1357
|
throw new Error(`failed to get pyth stale price feed id, msg: ${n.message}`);
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
|
-
async function
|
|
1360
|
+
async function $e(e, n) {
|
|
1361
1361
|
try {
|
|
1362
|
-
const o = [], r = n?.client ??
|
|
1362
|
+
const o = [], r = n?.client ?? $, t = e.map((c) => c.priceInfoObject), a = await r.multiGetObjects({
|
|
1363
1363
|
ids: Array.from(new Set(t)),
|
|
1364
1364
|
options: { showContent: !0 }
|
|
1365
1365
|
});
|
|
@@ -1369,12 +1369,12 @@ async function Pe(e, n) {
|
|
|
1369
1369
|
console.warn(`fetched object ${i?.objectId} datatype should be moveObject`);
|
|
1370
1370
|
continue;
|
|
1371
1371
|
}
|
|
1372
|
-
const s = e.find((
|
|
1372
|
+
const s = e.find((u) => u.priceInfoObject == i.objectId);
|
|
1373
1373
|
if (!s) {
|
|
1374
1374
|
console.warn(`unable to find pyth info from array, priceInfoObject: ${i.objectId}`);
|
|
1375
1375
|
continue;
|
|
1376
1376
|
}
|
|
1377
|
-
const
|
|
1377
|
+
const l = i.content.fields.price_info.fields.price_feed.fields.price.fields, { magnitude: d, negative: y } = l.price.fields, v = l.conf, g = l.timestamp;
|
|
1378
1378
|
o.push({
|
|
1379
1379
|
priceFeedId: s.priceFeedId,
|
|
1380
1380
|
priceInfoObject: s.priceInfoObject,
|
|
@@ -1392,7 +1392,7 @@ async function Pe(e, n) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
async function Se(e, n) {
|
|
1394
1394
|
try {
|
|
1395
|
-
const o = [], r = await
|
|
1395
|
+
const o = [], r = await $e(e, n);
|
|
1396
1396
|
if (!r) return o;
|
|
1397
1397
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
1398
1398
|
for (const a of r) {
|
|
@@ -1413,7 +1413,7 @@ async function Se(e, n) {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
}
|
|
1415
1415
|
async function Ve(e, n, o) {
|
|
1416
|
-
const r = o?.client ??
|
|
1416
|
+
const r = o?.client ?? $, t = await _({
|
|
1417
1417
|
...o,
|
|
1418
1418
|
cacheTime: b
|
|
1419
1419
|
});
|
|
@@ -1507,10 +1507,10 @@ async function mt(e, n, o, r) {
|
|
|
1507
1507
|
const t = await ne({
|
|
1508
1508
|
...r
|
|
1509
1509
|
}), a = [];
|
|
1510
|
-
o.forEach((
|
|
1511
|
-
a.includes(
|
|
1510
|
+
o.forEach((l) => {
|
|
1511
|
+
a.includes(l.market) || a.push(l.market);
|
|
1512
1512
|
});
|
|
1513
|
-
const c = await
|
|
1513
|
+
const c = await Pe(n, {
|
|
1514
1514
|
...r,
|
|
1515
1515
|
markets: a
|
|
1516
1516
|
}), i = Ee(t, {
|
|
@@ -1527,7 +1527,7 @@ async function mt(e, n, o, r) {
|
|
|
1527
1527
|
return console.error(t), e;
|
|
1528
1528
|
}
|
|
1529
1529
|
}
|
|
1530
|
-
const G =
|
|
1530
|
+
const G = P(
|
|
1531
1531
|
B(
|
|
1532
1532
|
async (e) => {
|
|
1533
1533
|
const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${S.version}&market=${e?.market || D}`, o = await fetch(n, { headers: M }).then((r) => r.json());
|
|
@@ -1554,7 +1554,7 @@ async function yt(e, n, o, r) {
|
|
|
1554
1554
|
))
|
|
1555
1555
|
throw new Error("Pool does not support flashloan");
|
|
1556
1556
|
if (t.version === 1) {
|
|
1557
|
-
const [s,
|
|
1557
|
+
const [s, l] = e.moveCall({
|
|
1558
1558
|
target: `${t.package}::lending::flash_loan_with_ctx`,
|
|
1559
1559
|
arguments: [
|
|
1560
1560
|
e.object(t.flashloanConfig),
|
|
@@ -1563,9 +1563,9 @@ async function yt(e, n, o, r) {
|
|
|
1563
1563
|
],
|
|
1564
1564
|
typeArguments: [a.suiCoinType]
|
|
1565
1565
|
});
|
|
1566
|
-
return [s,
|
|
1566
|
+
return [s, l];
|
|
1567
1567
|
} else {
|
|
1568
|
-
const [s,
|
|
1568
|
+
const [s, l] = e.moveCall({
|
|
1569
1569
|
target: `${t.package}::lending::flash_loan_with_ctx_v2`,
|
|
1570
1570
|
arguments: [
|
|
1571
1571
|
e.object(t.flashloanConfig),
|
|
@@ -1575,7 +1575,7 @@ async function yt(e, n, o, r) {
|
|
|
1575
1575
|
],
|
|
1576
1576
|
typeArguments: [a.suiCoinType]
|
|
1577
1577
|
});
|
|
1578
|
-
return [s,
|
|
1578
|
+
return [s, l];
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
1581
1581
|
async function gt(e, n, o, r, t) {
|
|
@@ -1590,7 +1590,7 @@ async function gt(e, n, o, r, t) {
|
|
|
1590
1590
|
(d) => k(d.coinType) === k(c.suiCoinType)
|
|
1591
1591
|
))
|
|
1592
1592
|
throw new Error("Pool does not support flashloan");
|
|
1593
|
-
const [
|
|
1593
|
+
const [l] = e.moveCall({
|
|
1594
1594
|
target: `${a.package}::lending::flash_repay_with_ctx`,
|
|
1595
1595
|
arguments: [
|
|
1596
1596
|
e.object("0x06"),
|
|
@@ -1601,13 +1601,13 @@ async function gt(e, n, o, r, t) {
|
|
|
1601
1601
|
],
|
|
1602
1602
|
typeArguments: [c.suiCoinType]
|
|
1603
1603
|
});
|
|
1604
|
-
return [
|
|
1604
|
+
return [l];
|
|
1605
1605
|
}
|
|
1606
1606
|
async function ht(e, n, o, r, t, a) {
|
|
1607
1607
|
const c = {
|
|
1608
1608
|
...a,
|
|
1609
1609
|
cacheTime: b
|
|
1610
|
-
}, i = await _(c), s = await A(n, c),
|
|
1610
|
+
}, i = await _(c), s = await A(n, c), l = await A(r, c);
|
|
1611
1611
|
if (i.version === 1) {
|
|
1612
1612
|
const [d, y] = e.moveCall({
|
|
1613
1613
|
target: `${i.package}::incentive_v3::liquidation`,
|
|
@@ -1624,9 +1624,9 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1624
1624
|
// Pay asset pool contract
|
|
1625
1625
|
h(o, e.object),
|
|
1626
1626
|
// Debt repayment amount
|
|
1627
|
-
e.pure.u8(
|
|
1627
|
+
e.pure.u8(l.id),
|
|
1628
1628
|
// Collateral asset ID
|
|
1629
|
-
e.object(
|
|
1629
|
+
e.object(l.contract.pool),
|
|
1630
1630
|
// Collateral asset pool contract
|
|
1631
1631
|
h(t, e.pure.address),
|
|
1632
1632
|
// Borrower address
|
|
@@ -1635,7 +1635,7 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1635
1635
|
e.object(i.incentiveV3)
|
|
1636
1636
|
// Incentive V3 contract
|
|
1637
1637
|
],
|
|
1638
|
-
typeArguments: [s.suiCoinType,
|
|
1638
|
+
typeArguments: [s.suiCoinType, l.suiCoinType]
|
|
1639
1639
|
});
|
|
1640
1640
|
return [d, y];
|
|
1641
1641
|
} else {
|
|
@@ -1654,9 +1654,9 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1654
1654
|
// Pay asset pool contract
|
|
1655
1655
|
h(o, e.object),
|
|
1656
1656
|
// Debt repayment amount
|
|
1657
|
-
e.pure.u8(
|
|
1657
|
+
e.pure.u8(l.id),
|
|
1658
1658
|
// Collateral asset ID
|
|
1659
|
-
e.object(
|
|
1659
|
+
e.object(l.contract.pool),
|
|
1660
1660
|
// Collateral asset pool contract
|
|
1661
1661
|
h(t, e.pure.address),
|
|
1662
1662
|
// Borrower address
|
|
@@ -1667,13 +1667,13 @@ async function ht(e, n, o, r, t, a) {
|
|
|
1667
1667
|
e.object("0x05")
|
|
1668
1668
|
// SuiSystemState object
|
|
1669
1669
|
],
|
|
1670
|
-
typeArguments: [s.suiCoinType,
|
|
1670
|
+
typeArguments: [s.suiCoinType, l.suiCoinType]
|
|
1671
1671
|
});
|
|
1672
1672
|
return [d, y];
|
|
1673
1673
|
}
|
|
1674
1674
|
}
|
|
1675
1675
|
async function De(e, n, o) {
|
|
1676
|
-
const r = o?.client ??
|
|
1676
|
+
const r = o?.client ?? $, t = new N(), a = await R({
|
|
1677
1677
|
...o,
|
|
1678
1678
|
markets: Object.values(E),
|
|
1679
1679
|
cacheTime: b
|
|
@@ -1723,24 +1723,24 @@ async function De(e, n, o) {
|
|
|
1723
1723
|
)
|
|
1724
1724
|
);
|
|
1725
1725
|
});
|
|
1726
|
-
const
|
|
1726
|
+
const l = [];
|
|
1727
1727
|
return s.forEach((d, y) => {
|
|
1728
1728
|
const v = n[y];
|
|
1729
1729
|
if (d.length === 5 && Array.isArray(d[0])) {
|
|
1730
1730
|
const g = d[0].length;
|
|
1731
|
-
for (let
|
|
1731
|
+
for (let u = 0; u < g; u++) {
|
|
1732
1732
|
const f = c.find(
|
|
1733
|
-
(I) => k(I.coinType) === k(d[1][
|
|
1733
|
+
(I) => k(I.coinType) === k(d[1][u])
|
|
1734
1734
|
), w = a.find(
|
|
1735
|
-
(I) => k(I.coinType) === k(d[0][
|
|
1735
|
+
(I) => k(I.coinType) === k(d[0][u]) && I.market === v.market
|
|
1736
1736
|
);
|
|
1737
|
-
!f || !w ||
|
|
1737
|
+
!f || !w || l.push({
|
|
1738
1738
|
assetId: w.id,
|
|
1739
|
-
assetCoinType: k(d[0][
|
|
1740
|
-
rewardCoinType: k(d[1][
|
|
1741
|
-
option: Number(d[2][
|
|
1742
|
-
userClaimableReward: Number(d[4][
|
|
1743
|
-
ruleIds: Array.isArray(d[3][
|
|
1739
|
+
assetCoinType: k(d[0][u]),
|
|
1740
|
+
rewardCoinType: k(d[1][u]),
|
|
1741
|
+
option: Number(d[2][u]),
|
|
1742
|
+
userClaimableReward: Number(d[4][u]) / Math.pow(10, f.priceDecimal),
|
|
1743
|
+
ruleIds: Array.isArray(d[3][u]) ? d[3][u] : [d[3][u]],
|
|
1744
1744
|
market: v.market,
|
|
1745
1745
|
owner: v.owner,
|
|
1746
1746
|
address: v.address,
|
|
@@ -1748,7 +1748,7 @@ async function De(e, n, o) {
|
|
|
1748
1748
|
});
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
|
-
}),
|
|
1751
|
+
}), l;
|
|
1752
1752
|
}
|
|
1753
1753
|
async function vt(e, n) {
|
|
1754
1754
|
const o = (n?.markets || [E.main]).map((a) => j(a));
|
|
@@ -1791,8 +1791,8 @@ function wt(e) {
|
|
|
1791
1791
|
for (const { assetId: r, rewardType: t, coinType: a, total: c, market: i } of n.values()) {
|
|
1792
1792
|
const s = `${r}-${t}-${i}`;
|
|
1793
1793
|
o.has(s) || o.set(s, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
|
|
1794
|
-
const
|
|
1795
|
-
|
|
1794
|
+
const l = o.get(s);
|
|
1795
|
+
l.rewards.set(a, (l.rewards.get(a) || 0) + c);
|
|
1796
1796
|
}
|
|
1797
1797
|
return Array.from(o.values()).map((r) => ({
|
|
1798
1798
|
assetId: r.assetId,
|
|
@@ -1824,33 +1824,31 @@ async function _t(e, n, o) {
|
|
|
1824
1824
|
cacheTime: b
|
|
1825
1825
|
}), t = /* @__PURE__ */ new Map();
|
|
1826
1826
|
for (const c of n) {
|
|
1827
|
-
const { rewardCoinType: i, ruleIds: s, market:
|
|
1828
|
-
for (const
|
|
1827
|
+
const { rewardCoinType: i, ruleIds: s, market: l, owner: d, address: y, emodeId: v } = c, g = `${i}___${y}`;
|
|
1828
|
+
for (const u of s) {
|
|
1829
1829
|
t.has(g) || t.set(g, {
|
|
1830
1830
|
assetIds: [],
|
|
1831
1831
|
ruleIds: [],
|
|
1832
1832
|
amount: 0,
|
|
1833
|
-
market:
|
|
1833
|
+
market: l,
|
|
1834
1834
|
owner: d,
|
|
1835
1835
|
address: y,
|
|
1836
1836
|
isEMode: typeof v < "u"
|
|
1837
1837
|
});
|
|
1838
1838
|
const f = t.get(g);
|
|
1839
|
-
f.assetIds.push(c.assetCoinType.replace("0x", "")), f.ruleIds.push(
|
|
1839
|
+
f.assetIds.push(c.assetCoinType.replace("0x", "")), f.ruleIds.push(u), f.amount += c.userClaimableReward;
|
|
1840
1840
|
}
|
|
1841
1841
|
}
|
|
1842
1842
|
const a = [];
|
|
1843
1843
|
for (const [
|
|
1844
1844
|
c,
|
|
1845
|
-
{ assetIds: i, ruleIds: s, amount:
|
|
1845
|
+
{ assetIds: i, ruleIds: s, amount: l, market: d, owner: y, address: v, isEMode: g }
|
|
1846
1846
|
] of t) {
|
|
1847
|
-
const
|
|
1847
|
+
const u = await _({
|
|
1848
1848
|
...o,
|
|
1849
1849
|
cacheTime: b,
|
|
1850
1850
|
market: d
|
|
1851
|
-
}), f = c.split("___")[0], w = r.find(
|
|
1852
|
-
(V) => k(V.suiCoinType) === k(f)
|
|
1853
|
-
);
|
|
1851
|
+
}), f = c.split("___")[0], w = r.find((V) => k(V.suiCoinType) === k(f));
|
|
1854
1852
|
if (!w || !w.contract.rewardFundId)
|
|
1855
1853
|
throw new Error(`No matching rewardFund found for reward coin: ${f} ${d}`);
|
|
1856
1854
|
const I = w.contract.rewardFundId;
|
|
@@ -1859,13 +1857,13 @@ async function _t(e, n, o) {
|
|
|
1859
1857
|
if (o?.customCoinReceive) {
|
|
1860
1858
|
let V;
|
|
1861
1859
|
o.accountCap ? V = e.moveCall({
|
|
1862
|
-
target: `${
|
|
1860
|
+
target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1863
1861
|
arguments: [
|
|
1864
1862
|
e.object("0x06"),
|
|
1865
1863
|
// Clock object
|
|
1866
|
-
e.object(
|
|
1864
|
+
e.object(u.incentiveV3),
|
|
1867
1865
|
// Incentive V3 contract
|
|
1868
|
-
e.object(
|
|
1866
|
+
e.object(u.storage),
|
|
1869
1867
|
// Protocol storage
|
|
1870
1868
|
e.object(I),
|
|
1871
1869
|
// Reward fund
|
|
@@ -1878,13 +1876,13 @@ async function _t(e, n, o) {
|
|
|
1878
1876
|
],
|
|
1879
1877
|
typeArguments: [f]
|
|
1880
1878
|
}) : g ? V = e.moveCall({
|
|
1881
|
-
target: `${
|
|
1879
|
+
target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1882
1880
|
arguments: [
|
|
1883
1881
|
e.object("0x06"),
|
|
1884
1882
|
// Clock object
|
|
1885
|
-
e.object(
|
|
1883
|
+
e.object(u.incentiveV3),
|
|
1886
1884
|
// Incentive V3 contract
|
|
1887
|
-
e.object(
|
|
1885
|
+
e.object(u.storage),
|
|
1888
1886
|
// Protocol storage
|
|
1889
1887
|
e.object(I),
|
|
1890
1888
|
// Reward fund
|
|
@@ -1897,13 +1895,13 @@ async function _t(e, n, o) {
|
|
|
1897
1895
|
],
|
|
1898
1896
|
typeArguments: [f]
|
|
1899
1897
|
}) : V = e.moveCall({
|
|
1900
|
-
target: `${
|
|
1898
|
+
target: `${u.package}::incentive_v3::claim_reward`,
|
|
1901
1899
|
arguments: [
|
|
1902
1900
|
e.object("0x06"),
|
|
1903
1901
|
// Clock object
|
|
1904
|
-
e.object(
|
|
1902
|
+
e.object(u.incentiveV3),
|
|
1905
1903
|
// Incentive V3 contract
|
|
1906
|
-
e.object(
|
|
1904
|
+
e.object(u.storage),
|
|
1907
1905
|
// Protocol storage
|
|
1908
1906
|
e.object(I),
|
|
1909
1907
|
// Reward fund
|
|
@@ -1929,7 +1927,7 @@ async function _t(e, n, o) {
|
|
|
1929
1927
|
}
|
|
1930
1928
|
if (o?.customCoinReceive.type === "depositNAVI") {
|
|
1931
1929
|
const re = p(w.totalSupplyAmount).shiftedBy(-9), ae = p(w.supplyCapCeiling).shiftedBy(-27);
|
|
1932
|
-
re.plus(
|
|
1930
|
+
re.plus(l).isGreaterThan(ae) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
1933
1931
|
[U],
|
|
1934
1932
|
e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
1935
1933
|
) : await _e(e, w, U, o);
|
|
@@ -1942,13 +1940,13 @@ async function _t(e, n, o) {
|
|
|
1942
1940
|
});
|
|
1943
1941
|
} else if (o?.accountCap || g) {
|
|
1944
1942
|
const V = e.moveCall({
|
|
1945
|
-
target: `${
|
|
1943
|
+
target: `${u.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1946
1944
|
arguments: [
|
|
1947
1945
|
e.object("0x06"),
|
|
1948
1946
|
// Clock object
|
|
1949
|
-
e.object(
|
|
1947
|
+
e.object(u.incentiveV3),
|
|
1950
1948
|
// Incentive V3 contract
|
|
1951
|
-
e.object(
|
|
1949
|
+
e.object(u.storage),
|
|
1952
1950
|
// Protocol storage
|
|
1953
1951
|
e.object(I),
|
|
1954
1952
|
// Reward fund
|
|
@@ -1971,13 +1969,13 @@ async function _t(e, n, o) {
|
|
|
1971
1969
|
);
|
|
1972
1970
|
} else
|
|
1973
1971
|
e.moveCall({
|
|
1974
|
-
target: `${
|
|
1972
|
+
target: `${u.package}::incentive_v3::claim_reward_entry`,
|
|
1975
1973
|
arguments: [
|
|
1976
1974
|
e.object("0x06"),
|
|
1977
1975
|
// Clock object
|
|
1978
|
-
e.object(
|
|
1976
|
+
e.object(u.incentiveV3),
|
|
1979
1977
|
// Incentive V3 contract
|
|
1980
|
-
e.object(
|
|
1978
|
+
e.object(u.storage),
|
|
1981
1979
|
// Protocol storage
|
|
1982
1980
|
e.object(I),
|
|
1983
1981
|
// Reward fund
|
|
@@ -2019,13 +2017,13 @@ export {
|
|
|
2019
2017
|
Te as getAccountCapOwnerPTB,
|
|
2020
2018
|
G as getAllFlashLoanAssets,
|
|
2021
2019
|
et as getBorrowFee,
|
|
2022
|
-
|
|
2020
|
+
ut as getCoins,
|
|
2023
2021
|
_ as getConfig,
|
|
2024
2022
|
Ze as getFees,
|
|
2025
2023
|
ft as getFlashLoanAsset,
|
|
2026
2024
|
ct as getHealthFactor,
|
|
2027
2025
|
Ae as getHealthFactorPTB,
|
|
2028
|
-
|
|
2026
|
+
Pe as getLendingPositions,
|
|
2029
2027
|
it as getLendingState,
|
|
2030
2028
|
tt as getMarket,
|
|
2031
2029
|
j as getMarketConfig,
|
|
@@ -2038,7 +2036,7 @@ export {
|
|
|
2038
2036
|
st as getSimulatedHealthFactor,
|
|
2039
2037
|
ee as getSimulatedHealthFactorPTB,
|
|
2040
2038
|
Je as getStats,
|
|
2041
|
-
|
|
2039
|
+
lt as getTransactions,
|
|
2042
2040
|
vt as getUserAvailableLendingRewards,
|
|
2043
2041
|
kt as getUserClaimedRewardHistory,
|
|
2044
2042
|
x as getUserEModeCaps,
|
|
@@ -2055,7 +2053,7 @@ export {
|
|
|
2055
2053
|
Me as updateOraclePricesPTB,
|
|
2056
2054
|
Ve as updatePythPriceFeeds,
|
|
2057
2055
|
pt as verifyHealthFactorPTB,
|
|
2058
|
-
|
|
2056
|
+
P as withCache,
|
|
2059
2057
|
B as withSingleton,
|
|
2060
2058
|
Qe as withdrawCoinPTB
|
|
2061
2059
|
};
|