@naviprotocol/lending 1.4.0-emode.12 → 1.4.0-emode.13
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 +5 -5
- 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 +459 -450
- package/dist/index.esm.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Transaction as
|
|
2
|
-
import { bcs as p, toHex as
|
|
3
|
-
import { SuiClient as
|
|
4
|
-
import
|
|
5
|
-
import { normalizeStructTag as
|
|
6
|
-
import { SuiPriceServiceConnection as
|
|
1
|
+
import { Transaction as U } from "@mysten/sui/transactions";
|
|
2
|
+
import { bcs as p, toHex as re, fromHex as ae } from "@mysten/bcs";
|
|
3
|
+
import { SuiClient as ce, getFullnodeUrl as ie } from "@mysten/sui/client";
|
|
4
|
+
import se from "lodash.camelcase";
|
|
5
|
+
import { normalizeStructTag as ue } from "@mysten/sui/utils";
|
|
6
|
+
import { SuiPriceServiceConnection as Y, SuiPythClient as le } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import l from "bignumber.js";
|
|
8
|
-
import { bcs as
|
|
9
|
-
const
|
|
8
|
+
import { bcs as C } from "@mysten/sui/bcs";
|
|
9
|
+
const W = p.bytes(32).transform({
|
|
10
10
|
// To change the input type, you need to provide a type definition for the input
|
|
11
|
-
input: (e) =>
|
|
12
|
-
output: (e) =>
|
|
13
|
-
}),
|
|
11
|
+
input: (e) => ae(e),
|
|
12
|
+
output: (e) => re(e)
|
|
13
|
+
}), qe = p.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
15
|
asset_id: p.u8(),
|
|
16
16
|
/** Annual Percentage Yield as a 256-bit integer */
|
|
17
17
|
apy: p.u256(),
|
|
18
18
|
/** List of supported coin types for this incentive */
|
|
19
19
|
coin_types: p.vector(p.string())
|
|
20
|
-
}),
|
|
20
|
+
}), pe = p.struct("IncentivePoolInfo", {
|
|
21
21
|
/** Unique pool identifier */
|
|
22
|
-
pool_id:
|
|
22
|
+
pool_id: W,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: W,
|
|
25
25
|
/** Current phase of the incentive program */
|
|
26
26
|
phase: p.u64(),
|
|
27
27
|
/** Timestamp when the incentive started */
|
|
@@ -48,8 +48,8 @@ const q = p.bytes(32).transform({
|
|
|
48
48
|
/** Phase number */
|
|
49
49
|
phase: p.u64(),
|
|
50
50
|
/** List of incentive pools in this phase */
|
|
51
|
-
pools: p.vector(
|
|
52
|
-
}),
|
|
51
|
+
pools: p.vector(pe)
|
|
52
|
+
}), We = p.struct("OracleInfo", {
|
|
53
53
|
/** Oracle identifier */
|
|
54
54
|
oracle_id: p.u8(),
|
|
55
55
|
/** Current price as a 256-bit integer */
|
|
@@ -58,7 +58,7 @@ const q = p.bytes(32).transform({
|
|
|
58
58
|
decimals: p.u8(),
|
|
59
59
|
/** Whether the oracle data is valid */
|
|
60
60
|
valid: p.bool()
|
|
61
|
-
}),
|
|
61
|
+
}), He = p.struct("FlashLoanAssetConfig", {
|
|
62
62
|
/** Unique identifier for the flash loan asset */
|
|
63
63
|
id: p.string(),
|
|
64
64
|
/** Asset identifier */
|
|
@@ -75,7 +75,7 @@ const q = p.bytes(32).transform({
|
|
|
75
75
|
max: p.u64(),
|
|
76
76
|
/** Minimum flash loan amount */
|
|
77
77
|
min: p.u64()
|
|
78
|
-
}),
|
|
78
|
+
}), Ge = p.struct("ReserveDataInfo", {
|
|
79
79
|
/** Reserve identifier */
|
|
80
80
|
id: p.u8(),
|
|
81
81
|
/** Oracle identifier for price feeds */
|
|
@@ -122,16 +122,16 @@ const q = p.bytes(32).transform({
|
|
|
122
122
|
liquidation_bonus: p.u256(),
|
|
123
123
|
/** Liquidation threshold */
|
|
124
124
|
liquidation_threshold: p.u256()
|
|
125
|
-
}),
|
|
125
|
+
}), de = p.struct("UserStateInfo", {
|
|
126
126
|
/** Asset identifier */
|
|
127
127
|
asset_id: p.u8(),
|
|
128
128
|
/** User's current borrow balance */
|
|
129
129
|
borrow_balance: p.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: p.u256()
|
|
132
|
-
}),
|
|
133
|
-
version:
|
|
134
|
-
},
|
|
132
|
+
}), me = "1.4.0-emode.13", S = {
|
|
133
|
+
version: me
|
|
134
|
+
}, ge = S.version, ye = () => {
|
|
135
135
|
if (typeof process < "u" && process.versions && process.versions.node)
|
|
136
136
|
try {
|
|
137
137
|
const e = require("os"), n = process.version, o = e.type(), r = e.arch();
|
|
@@ -142,16 +142,16 @@ const q = p.bytes(32).transform({
|
|
|
142
142
|
return "Node/Unknown";
|
|
143
143
|
}, fe = () => {
|
|
144
144
|
let e = "";
|
|
145
|
-
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${
|
|
146
|
-
},
|
|
145
|
+
return typeof process < "u" && process.versions && process.versions.node && (e = `lending/${ge} (${ye()})`), e;
|
|
146
|
+
}, H = fe(), $ = new ce({
|
|
147
147
|
url: ie("mainnet")
|
|
148
148
|
});
|
|
149
|
-
function
|
|
149
|
+
function J(e) {
|
|
150
150
|
const n = [];
|
|
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:
|
|
154
|
+
const { client: a, disableCache: i, cacheTime: c, ...s } = o;
|
|
155
155
|
n.push(s);
|
|
156
156
|
} else
|
|
157
157
|
n.push(o);
|
|
@@ -160,7 +160,7 @@ function Y(e) {
|
|
|
160
160
|
function I(e) {
|
|
161
161
|
const n = {};
|
|
162
162
|
return (...o) => {
|
|
163
|
-
const r =
|
|
163
|
+
const r = J(o);
|
|
164
164
|
return n[r] || (n[r] = e(...o).finally(() => {
|
|
165
165
|
delete n[r];
|
|
166
166
|
})), n[r];
|
|
@@ -169,29 +169,29 @@ function I(e) {
|
|
|
169
169
|
function A(e) {
|
|
170
170
|
let n = {};
|
|
171
171
|
return (...o) => {
|
|
172
|
-
const r = o[o.length - 1], 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:
|
|
172
|
+
const r = o[o.length - 1], t = J(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((i) => (n[t] = {
|
|
174
|
+
data: i,
|
|
175
175
|
cacheAt: Date.now()
|
|
176
|
-
},
|
|
176
|
+
}, i));
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
return Array.isArray(e) ? e.map((n) =>
|
|
179
|
+
function F(e) {
|
|
180
|
+
return Array.isArray(e) ? e.map((n) => F(n)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
181
181
|
(n, o) => ({
|
|
182
182
|
...n,
|
|
183
|
-
[
|
|
183
|
+
[se(o)]: F(e[o])
|
|
184
184
|
}),
|
|
185
185
|
{}
|
|
186
186
|
) : e;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function y(e, n) {
|
|
189
189
|
return typeof e == "object" ? e : n(e);
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function ve(e, n) {
|
|
192
192
|
return typeof n == "string" ? e.object(n) : typeof n == "object" && n.$kind ? n : e.object(n.contract.pool);
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function O(e, n, o) {
|
|
195
195
|
if (e.results && e.results.length > 0) {
|
|
196
196
|
if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
|
|
197
197
|
return e.results[0].returnValues.map((r, t) => (n[t] || n[0]).parse(Uint8Array.from(r[0])));
|
|
@@ -200,35 +200,35 @@ function R(e, n, o) {
|
|
|
200
200
|
return [];
|
|
201
201
|
}
|
|
202
202
|
function b(e) {
|
|
203
|
-
return
|
|
203
|
+
return ue(e);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Q(e) {
|
|
206
206
|
const n = (e || 0) / Math.pow(10, 27);
|
|
207
207
|
return n > Math.pow(10, 5) ? 1 / 0 : n;
|
|
208
208
|
}
|
|
209
|
-
new
|
|
209
|
+
new Y("https://hermes.pyth.network", {
|
|
210
210
|
timeout: 2e4
|
|
211
211
|
});
|
|
212
|
-
const
|
|
212
|
+
const we = 27, G = (e, n) => {
|
|
213
213
|
if (!Number(e) || !Number(n)) return new l(0);
|
|
214
|
-
const o = new l(1).shiftedBy(1 *
|
|
214
|
+
const o = new l(1).shiftedBy(1 * we), r = o.multipliedBy(new l(0.5));
|
|
215
215
|
return new l(e).multipliedBy(new l(n)).plus(r).dividedBy(o).integerValue(l.ROUND_DOWN);
|
|
216
|
-
}, V =
|
|
217
|
-
"User-Agent":
|
|
216
|
+
}, V = H ? {
|
|
217
|
+
"User-Agent": H
|
|
218
218
|
} : {};
|
|
219
|
-
function
|
|
219
|
+
function q(e, n = "uniqueId") {
|
|
220
220
|
return e.reduce(
|
|
221
221
|
(o, r) => (o[n] = r, o),
|
|
222
222
|
{}
|
|
223
223
|
);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function z(e, n = "uniqueId") {
|
|
226
226
|
return e.reduce(
|
|
227
227
|
(o, r) => (o[n] = r, o),
|
|
228
228
|
{}
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function K(e, n) {
|
|
232
232
|
const o = e.emodes.find((t) => t.emodeId === n.emodeId);
|
|
233
233
|
if (!o)
|
|
234
234
|
throw new Error("EMode not found in pool");
|
|
@@ -242,34 +242,34 @@ function z(e, n) {
|
|
|
242
242
|
isEMode: !0
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function he(e) {
|
|
246
246
|
const [n, o] = e.split("-");
|
|
247
247
|
return !n || !o ? null : {
|
|
248
248
|
marketKey: n,
|
|
249
249
|
poolId: parseInt(o)
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function P() {
|
|
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
|
-
var
|
|
256
|
-
const
|
|
255
|
+
var N = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(N || {});
|
|
256
|
+
const R = A(
|
|
257
257
|
I(
|
|
258
258
|
async (e) => {
|
|
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=${
|
|
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(
|
|
260
260
|
(t) => t.key
|
|
261
261
|
)}`, r = await fetch(o, { headers: V }).then((t) => t.json());
|
|
262
262
|
return r.data.forEach((t) => {
|
|
263
|
-
const
|
|
264
|
-
const
|
|
265
|
-
return t.market ===
|
|
266
|
-
}).filter((h) => !!h.assets.find((
|
|
267
|
-
t.emodes =
|
|
268
|
-
const
|
|
263
|
+
const i = r.meta.emodes.filter((h) => {
|
|
264
|
+
const _ = j(h.marketId);
|
|
265
|
+
return t.market === _.key && h.isActive;
|
|
266
|
+
}).filter((h) => !!h.assets.find((_) => _.assetId === t.id));
|
|
267
|
+
t.emodes = i;
|
|
268
|
+
const c = l(t.totalSupplyAmount).div(Math.pow(10, 9)).decimalPlaces(t.token.decimals, l.ROUND_DOWN).toString(), s = l(t.borrowedAmount).shiftedBy(-9).decimalPlaces(t.token.decimals, l.ROUND_DOWN).toString(), u = l(c).multipliedBy(t.oracle.price).toString(), m = l(s).multipliedBy(t.oracle.price).toString(), d = l(t.supplyCapCeiling).shiftedBy(-27).decimalPlaces(t.token.decimals, l.ROUND_DOWN).toString(), g = l.max(
|
|
269
269
|
l(t.borrowedAmount),
|
|
270
270
|
l(t.validBorrowAmount)
|
|
271
|
-
).shiftedBy(-9).decimalPlaces(t.token.decimals, l.ROUND_DOWN).toString(), v = l(d).multipliedBy(t.oracle.price).toString(),
|
|
272
|
-
t.poolSupplyAmount =
|
|
271
|
+
).shiftedBy(-9).decimalPlaces(t.token.decimals, l.ROUND_DOWN).toString(), v = l(d).multipliedBy(t.oracle.price).toString(), f = l(g).multipliedBy(t.oracle.price).toString();
|
|
272
|
+
t.poolSupplyAmount = c, t.poolBorrowAmount = s, t.poolSupplyValue = u, t.poolBorrowValue = m, t.poolSupplyCapAmount = d, t.poolBorrowCapAmount = g, t.poolSupplyCapValue = v, t.poolBorrowCapValue = f;
|
|
273
273
|
}), r.data;
|
|
274
274
|
}
|
|
275
275
|
)
|
|
@@ -277,12 +277,12 @@ const N = A(
|
|
|
277
277
|
async function B(e, n) {
|
|
278
278
|
let o = n?.market;
|
|
279
279
|
if (typeof e == "string") {
|
|
280
|
-
const a =
|
|
280
|
+
const a = he(e);
|
|
281
281
|
a && (o = a.marketKey, e = a.poolId);
|
|
282
282
|
}
|
|
283
|
-
const r = await
|
|
283
|
+
const r = await R({
|
|
284
284
|
...n,
|
|
285
|
-
markets: [o ||
|
|
285
|
+
markets: [o || D],
|
|
286
286
|
cacheTime: w
|
|
287
287
|
});
|
|
288
288
|
if (typeof e == "object")
|
|
@@ -292,36 +292,36 @@ async function B(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
|
|
295
|
+
const ze = A(
|
|
296
296
|
I(async (e) => {
|
|
297
|
-
const n = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${
|
|
297
|
+
const n = `https://open-api.naviprotocol.io/api/navi/stats?sdk=${S.version}`;
|
|
298
298
|
return (await fetch(n, { headers: V }).then((r) => r.json())).data;
|
|
299
299
|
})
|
|
300
|
-
),
|
|
300
|
+
), Ke = A(
|
|
301
301
|
I(
|
|
302
302
|
async (e) => {
|
|
303
|
-
const n = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${
|
|
303
|
+
const n = `https://open-api.naviprotocol.io/api/navi/fee?sdk=${S.version}`;
|
|
304
304
|
return await fetch(n, { headers: V }).then((r) => r.json());
|
|
305
305
|
}
|
|
306
306
|
)
|
|
307
307
|
);
|
|
308
|
-
async function
|
|
308
|
+
async function be(e, n, o, r) {
|
|
309
309
|
const t = await k({
|
|
310
310
|
...r,
|
|
311
311
|
cacheTime: w
|
|
312
312
|
}), a = await B(n, r);
|
|
313
313
|
if (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 (b(a.suiCoinType) === b("0x2::sui::SUI") &&
|
|
315
|
+
const i = typeof o == "object" && o.$kind === "GasCoin";
|
|
316
|
+
if (b(a.suiCoinType) === b("0x2::sui::SUI") && i) {
|
|
317
317
|
if (!r?.amount)
|
|
318
318
|
throw new Error("Amount is required for sui coin");
|
|
319
319
|
o = e.splitCoins(o, [r.amount]);
|
|
320
320
|
}
|
|
321
|
-
let
|
|
322
|
-
return typeof r?.amount < "u" ?
|
|
321
|
+
let c;
|
|
322
|
+
return typeof r?.amount < "u" ? c = y(r.amount, e.pure.u64) : c = e.moveCall({
|
|
323
323
|
target: "0x2::coin::value",
|
|
324
|
-
arguments: [
|
|
324
|
+
arguments: [y(o, e.object)],
|
|
325
325
|
typeArguments: [a.suiCoinType]
|
|
326
326
|
}), r?.accountCap ? e.moveCall({
|
|
327
327
|
target: `${t.package}::incentive_v3::deposit_with_account_cap`,
|
|
@@ -330,10 +330,10 @@ async function he(e, n, o, r) {
|
|
|
330
330
|
e.object(t.storage),
|
|
331
331
|
e.object(a.contract.pool),
|
|
332
332
|
e.pure.u8(a.id),
|
|
333
|
-
|
|
333
|
+
y(o, e.object),
|
|
334
334
|
e.object(t.incentiveV2),
|
|
335
335
|
e.object(t.incentiveV3),
|
|
336
|
-
|
|
336
|
+
y(r.accountCap, e.object)
|
|
337
337
|
],
|
|
338
338
|
typeArguments: [a.suiCoinType]
|
|
339
339
|
}) : e.moveCall({
|
|
@@ -343,8 +343,8 @@ async function he(e, n, o, r) {
|
|
|
343
343
|
e.object(t.storage),
|
|
344
344
|
e.object(a.contract.pool),
|
|
345
345
|
e.pure.u8(a.id),
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
y(o, e.object),
|
|
347
|
+
c,
|
|
348
348
|
e.object(t.incentiveV2),
|
|
349
349
|
e.object(t.incentiveV3)
|
|
350
350
|
],
|
|
@@ -354,12 +354,12 @@ async function he(e, n, o, r) {
|
|
|
354
354
|
arguments: [e.object(a.contract.pool), e.object("0x05")]
|
|
355
355
|
}), e;
|
|
356
356
|
}
|
|
357
|
-
async function
|
|
357
|
+
async function Ye(e, n, o, r) {
|
|
358
358
|
const t = await k({
|
|
359
359
|
...r,
|
|
360
360
|
cacheTime: w
|
|
361
|
-
}), a = await B(n, r),
|
|
362
|
-
let
|
|
361
|
+
}), a = await B(n, r), i = y(o, e.pure.u64);
|
|
362
|
+
let c;
|
|
363
363
|
if (t.version === 1)
|
|
364
364
|
if (r?.accountCap) {
|
|
365
365
|
const [u] = e.moveCall({
|
|
@@ -370,14 +370,14 @@ async function Ke(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
|
+
i,
|
|
374
374
|
e.object(t.incentiveV2),
|
|
375
375
|
e.object(t.incentiveV3),
|
|
376
|
-
|
|
376
|
+
y(r.accountCap, e.object)
|
|
377
377
|
],
|
|
378
378
|
typeArguments: [a.suiCoinType]
|
|
379
379
|
});
|
|
380
|
-
|
|
380
|
+
c = u;
|
|
381
381
|
} else {
|
|
382
382
|
const [u] = e.moveCall({
|
|
383
383
|
target: `${t.package}::incentive_v3::withdraw`,
|
|
@@ -387,13 +387,13 @@ async function Ke(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
|
+
i,
|
|
391
391
|
e.object(t.incentiveV2),
|
|
392
392
|
e.object(t.incentiveV3)
|
|
393
393
|
],
|
|
394
394
|
typeArguments: [a.suiCoinType]
|
|
395
395
|
});
|
|
396
|
-
|
|
396
|
+
c = u;
|
|
397
397
|
}
|
|
398
398
|
else if (r?.accountCap) {
|
|
399
399
|
const [u] = e.moveCall({
|
|
@@ -404,15 +404,15 @@ async function Ke(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
|
+
i,
|
|
408
408
|
e.object(t.incentiveV2),
|
|
409
409
|
e.object(t.incentiveV3),
|
|
410
|
-
|
|
410
|
+
y(r.accountCap, e.object),
|
|
411
411
|
e.object("0x05")
|
|
412
412
|
],
|
|
413
413
|
typeArguments: [a.suiCoinType]
|
|
414
414
|
});
|
|
415
|
-
|
|
415
|
+
c = u;
|
|
416
416
|
} else {
|
|
417
417
|
const [u] = e.moveCall({
|
|
418
418
|
target: `${t.package}::incentive_v3::withdraw_v2`,
|
|
@@ -422,30 +422,30 @@ async function Ke(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
|
+
i,
|
|
426
426
|
e.object(t.incentiveV2),
|
|
427
427
|
e.object(t.incentiveV3),
|
|
428
428
|
e.object("0x05")
|
|
429
429
|
],
|
|
430
430
|
typeArguments: [a.suiCoinType]
|
|
431
431
|
});
|
|
432
|
-
|
|
432
|
+
c = u;
|
|
433
433
|
}
|
|
434
434
|
return e.moveCall({
|
|
435
435
|
target: "0x2::coin::from_balance",
|
|
436
|
-
arguments: [
|
|
436
|
+
arguments: [c],
|
|
437
437
|
typeArguments: [a.suiCoinType]
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
|
-
async function
|
|
440
|
+
async function Je(e, n, o, r) {
|
|
441
441
|
const t = await k({
|
|
442
442
|
...r,
|
|
443
443
|
cacheTime: w
|
|
444
444
|
}), a = await B(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
|
|
448
|
-
let
|
|
447
|
+
const i = y(o, e.pure.u64);
|
|
448
|
+
let c;
|
|
449
449
|
if (t.version === 1)
|
|
450
450
|
if (r?.accountCap) {
|
|
451
451
|
const [u] = e.moveCall({
|
|
@@ -456,14 +456,14 @@ async function Ye(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
|
+
i,
|
|
460
460
|
e.object(t.incentiveV2),
|
|
461
461
|
e.object(t.incentiveV3),
|
|
462
|
-
|
|
462
|
+
y(r.accountCap, e.object)
|
|
463
463
|
],
|
|
464
464
|
typeArguments: [a.suiCoinType]
|
|
465
465
|
});
|
|
466
|
-
|
|
466
|
+
c = u;
|
|
467
467
|
} else {
|
|
468
468
|
const [u] = e.moveCall({
|
|
469
469
|
target: `${t.package}::incentive_v3::borrow`,
|
|
@@ -473,13 +473,13 @@ async function Ye(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
|
+
i,
|
|
477
477
|
e.object(t.incentiveV2),
|
|
478
478
|
e.object(t.incentiveV3)
|
|
479
479
|
],
|
|
480
480
|
typeArguments: [a.suiCoinType]
|
|
481
481
|
});
|
|
482
|
-
|
|
482
|
+
c = u;
|
|
483
483
|
}
|
|
484
484
|
else if (r?.accountCap) {
|
|
485
485
|
const [u] = e.moveCall({
|
|
@@ -490,15 +490,15 @@ async function Ye(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
|
+
i,
|
|
494
494
|
e.object(t.incentiveV2),
|
|
495
495
|
e.object(t.incentiveV3),
|
|
496
|
-
|
|
496
|
+
y(r.accountCap, e.object),
|
|
497
497
|
e.object("0x05")
|
|
498
498
|
],
|
|
499
499
|
typeArguments: [a.suiCoinType]
|
|
500
500
|
});
|
|
501
|
-
|
|
501
|
+
c = u;
|
|
502
502
|
} else {
|
|
503
503
|
const [u] = e.moveCall({
|
|
504
504
|
target: `${t.package}::incentive_v3::borrow_v2`,
|
|
@@ -508,35 +508,35 @@ async function Ye(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
|
+
i,
|
|
512
512
|
e.object(t.incentiveV2),
|
|
513
513
|
e.object(t.incentiveV3),
|
|
514
514
|
e.object("0x05")
|
|
515
515
|
],
|
|
516
516
|
typeArguments: [a.suiCoinType]
|
|
517
517
|
});
|
|
518
|
-
|
|
518
|
+
c = u;
|
|
519
519
|
}
|
|
520
520
|
return e.moveCall({
|
|
521
521
|
target: "0x2::coin::from_balance",
|
|
522
|
-
arguments: [e.object(
|
|
522
|
+
arguments: [e.object(c)],
|
|
523
523
|
typeArguments: [a.suiCoinType]
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
async function
|
|
526
|
+
async function Qe(e, n, o, r) {
|
|
527
527
|
const t = await k({
|
|
528
528
|
...r,
|
|
529
529
|
cacheTime: w
|
|
530
|
-
}), a = await B(n, r),
|
|
531
|
-
if (b(a.suiCoinType) === b("0x2::sui::SUI") &&
|
|
530
|
+
}), a = await B(n, r), i = typeof o == "object" && o.$kind === "GasCoin";
|
|
531
|
+
if (b(a.suiCoinType) === b("0x2::sui::SUI") && i) {
|
|
532
532
|
if (!r?.amount)
|
|
533
533
|
throw new Error("Amount is required for sui coin");
|
|
534
534
|
o = e.splitCoins(o, [r.amount]);
|
|
535
535
|
}
|
|
536
|
-
let
|
|
537
|
-
if (typeof r?.amount < "u" ?
|
|
536
|
+
let c;
|
|
537
|
+
if (typeof r?.amount < "u" ? c = y(r.amount, e.pure.u64) : c = e.moveCall({
|
|
538
538
|
target: "0x2::coin::value",
|
|
539
|
-
arguments: [
|
|
539
|
+
arguments: [y(o, e.object)],
|
|
540
540
|
typeArguments: [a.suiCoinType]
|
|
541
541
|
}), r?.accountCap) {
|
|
542
542
|
const [s] = e.moveCall({
|
|
@@ -547,10 +547,10 @@ async function Je(e, n, o, r) {
|
|
|
547
547
|
e.object(t.storage),
|
|
548
548
|
e.object(a.contract.pool),
|
|
549
549
|
e.pure.u8(a.id),
|
|
550
|
-
|
|
550
|
+
y(o, e.object),
|
|
551
551
|
e.object(t.incentiveV2),
|
|
552
552
|
e.object(t.incentiveV3),
|
|
553
|
-
|
|
553
|
+
y(r.accountCap, e.object)
|
|
554
554
|
],
|
|
555
555
|
typeArguments: [a.suiCoinType]
|
|
556
556
|
});
|
|
@@ -568,15 +568,15 @@ async function Je(e, n, o, r) {
|
|
|
568
568
|
e.object(t.storage),
|
|
569
569
|
e.object(a.contract.pool),
|
|
570
570
|
e.pure.u8(a.id),
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
y(o, e.object),
|
|
572
|
+
c,
|
|
573
573
|
e.object(t.incentiveV2),
|
|
574
574
|
e.object(t.incentiveV3)
|
|
575
575
|
],
|
|
576
576
|
typeArguments: [a.suiCoinType]
|
|
577
577
|
}), e;
|
|
578
578
|
}
|
|
579
|
-
const
|
|
579
|
+
const Xe = A(
|
|
580
580
|
I(
|
|
581
581
|
async (e) => {
|
|
582
582
|
const n = await k({
|
|
@@ -584,21 +584,21 @@ const Qe = A(
|
|
|
584
584
|
});
|
|
585
585
|
if (e?.address && typeof e?.asset < "u")
|
|
586
586
|
try {
|
|
587
|
-
const t = await B(e.asset, e), a = e?.client ?? $,
|
|
588
|
-
|
|
587
|
+
const t = await B(e.asset, e), a = e?.client ?? $, i = new U();
|
|
588
|
+
i.moveCall({
|
|
589
589
|
target: `${n.package}::incentive_v3::get_borrow_fee_v2`,
|
|
590
590
|
arguments: [
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
i.object(n.incentiveV3),
|
|
592
|
+
i.pure.address(e.address),
|
|
593
|
+
i.pure.u8(t.id),
|
|
594
|
+
i.pure.u64(1e4)
|
|
595
595
|
],
|
|
596
596
|
typeArguments: []
|
|
597
597
|
});
|
|
598
|
-
const
|
|
599
|
-
transactionBlock:
|
|
598
|
+
const c = await a.devInspectTransactionBlock({
|
|
599
|
+
transactionBlock: i,
|
|
600
600
|
sender: e.address
|
|
601
|
-
}), s =
|
|
601
|
+
}), s = O(c, [C.u64()]);
|
|
602
602
|
return (Number(s[0]) || 0) / 100;
|
|
603
603
|
} catch (t) {
|
|
604
604
|
console.error(t);
|
|
@@ -610,14 +610,14 @@ const Qe = A(
|
|
|
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
618
|
}
|
|
619
619
|
};
|
|
620
|
-
class
|
|
620
|
+
class ke {
|
|
621
621
|
constructor(n, o) {
|
|
622
622
|
this.poolMap = {}, this.emodeMap = {}, this.pools = [], this.emodes = [], this.emodePools = [], this.emodeBorrowablePools = [], this.emodeSupplyablePools = [], this._overview = {
|
|
623
623
|
marketTotalSupplyValue: "0",
|
|
@@ -628,8 +628,8 @@ class be {
|
|
|
628
628
|
return this._overview;
|
|
629
629
|
}
|
|
630
630
|
addPools(n) {
|
|
631
|
-
const o =
|
|
632
|
-
let
|
|
631
|
+
const o = q(this.pools), r = z(this.emodes), t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
632
|
+
let i = l(0), c = l(0);
|
|
633
633
|
n.forEach((s) => {
|
|
634
634
|
if (!this.checkMarket(s.market)) {
|
|
635
635
|
console.warn(`Pool is not in market ${this.config.name}`, s);
|
|
@@ -639,30 +639,30 @@ class be {
|
|
|
639
639
|
r[m.uniqueId] || this.emodes.push(m), m.assets.forEach((d) => {
|
|
640
640
|
d.isDebt && t.add(s.uniqueId), d.isCollateral && a.add(s.uniqueId);
|
|
641
641
|
});
|
|
642
|
-
}),
|
|
643
|
-
}), this.poolMap =
|
|
642
|
+
}), c = c.plus(s.poolBorrowValue), i = i.plus(s.poolSupplyValue);
|
|
643
|
+
}), this.poolMap = q(this.pools, "id"), this.emodeMap = z(this.emodes, "emodeId"), this.emodes.forEach((s) => {
|
|
644
644
|
const u = this.getEModePools(s.emodeId);
|
|
645
645
|
this.emodePools.push(...u);
|
|
646
646
|
}), this._overview = {
|
|
647
|
-
marketTotalSupplyValue:
|
|
648
|
-
marketTotalBorrowValue:
|
|
647
|
+
marketTotalSupplyValue: i.toString(),
|
|
648
|
+
marketTotalBorrowValue: c.toString()
|
|
649
649
|
}, this.emodeBorrowablePools = this.pools.filter((s) => t.has(s.uniqueId)), this.emodeSupplyablePools = this.pools.filter((s) => a.has(s.uniqueId));
|
|
650
650
|
}
|
|
651
651
|
getEMode(n) {
|
|
652
652
|
return this.emodeMap[n] || null;
|
|
653
653
|
}
|
|
654
654
|
getEModeRelatePools(n, o) {
|
|
655
|
-
const { collateral: r, debt: t, emodeId: a } = o || {},
|
|
656
|
-
return n.emodes.forEach((
|
|
657
|
-
typeof a == "number" && a !==
|
|
658
|
-
typeof r == "boolean" && r && s.isCollateral && s.assetId === n.id &&
|
|
655
|
+
const { collateral: r, debt: t, emodeId: a } = o || {}, i = [];
|
|
656
|
+
return n.emodes.forEach((c) => {
|
|
657
|
+
typeof a == "number" && a !== c.emodeId || c.assets.forEach((s) => {
|
|
658
|
+
typeof r == "boolean" && r && s.isCollateral && s.assetId === n.id && i.push(this.poolMap[s.assetId]), typeof t == "boolean" && t && s.isDebt && s.assetId === n.id && i.push(this.poolMap[s.assetId]);
|
|
659
659
|
});
|
|
660
|
-
}),
|
|
660
|
+
}), i;
|
|
661
661
|
}
|
|
662
662
|
getEModePools(n) {
|
|
663
663
|
const o = this.getEMode(n);
|
|
664
664
|
return o ? o.assets.map((t) => t.assetId).map((t) => this.poolMap[t]).filter((t) => !!t).map((t) => {
|
|
665
|
-
const a = o.assets.find((
|
|
665
|
+
const a = o.assets.find((i) => i.assetId === t.id);
|
|
666
666
|
return {
|
|
667
667
|
...t,
|
|
668
668
|
emode: {
|
|
@@ -683,28 +683,28 @@ const j = (e) => {
|
|
|
683
683
|
if (!o)
|
|
684
684
|
throw new Error("Market not found");
|
|
685
685
|
return o;
|
|
686
|
-
},
|
|
686
|
+
}, Ce = A(
|
|
687
687
|
I(
|
|
688
688
|
async (e, n) => {
|
|
689
|
-
const o = await
|
|
689
|
+
const o = await R({
|
|
690
690
|
cacheTime: 6e4,
|
|
691
691
|
...n,
|
|
692
692
|
markets: e
|
|
693
693
|
});
|
|
694
694
|
return e.map((r) => {
|
|
695
|
-
const t = j(r), a = o.filter((
|
|
696
|
-
return new
|
|
695
|
+
const t = j(r), a = o.filter((i) => i.market === t.key);
|
|
696
|
+
return new ke(r, a);
|
|
697
697
|
});
|
|
698
698
|
}
|
|
699
699
|
)
|
|
700
|
-
),
|
|
700
|
+
), Ze = A(
|
|
701
701
|
I(
|
|
702
|
-
async (e, n) => (await
|
|
702
|
+
async (e, n) => (await Ce([e], n))[0]
|
|
703
703
|
)
|
|
704
704
|
), k = A(
|
|
705
705
|
I(
|
|
706
706
|
async (e) => {
|
|
707
|
-
const n = j(e?.market ||
|
|
707
|
+
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}`;
|
|
708
708
|
return (await fetch(o, { headers: V }).then((t) => t.json())).data;
|
|
709
709
|
}
|
|
710
710
|
)
|
|
@@ -719,7 +719,7 @@ async function _e(e, n) {
|
|
|
719
719
|
arguments: []
|
|
720
720
|
});
|
|
721
721
|
}
|
|
722
|
-
async function
|
|
722
|
+
async function je(e, n, o) {
|
|
723
723
|
const r = await k({
|
|
724
724
|
cacheTime: w,
|
|
725
725
|
...o
|
|
@@ -729,7 +729,7 @@ async function Ce(e, n, o) {
|
|
|
729
729
|
arguments: [n]
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
|
-
async function
|
|
732
|
+
async function Te(e, n, o) {
|
|
733
733
|
const r = await k({
|
|
734
734
|
...o,
|
|
735
735
|
cacheTime: w
|
|
@@ -738,63 +738,63 @@ async function je(e, n, o) {
|
|
|
738
738
|
target: `${r.package}::lending::enter_emode_with_account_cap`,
|
|
739
739
|
arguments: [
|
|
740
740
|
e.object(r.storage),
|
|
741
|
-
|
|
742
|
-
|
|
741
|
+
y(n, e.pure.u64),
|
|
742
|
+
y(o.accountCap, e.object)
|
|
743
743
|
]
|
|
744
744
|
}) : e.moveCall({
|
|
745
745
|
target: `${r.package}::lending::enter_emode`,
|
|
746
|
-
arguments: [e.object(r.storage),
|
|
746
|
+
arguments: [e.object(r.storage), y(n, e.pure.u64)]
|
|
747
747
|
}), e;
|
|
748
748
|
}
|
|
749
|
-
async function
|
|
749
|
+
async function xe(e, n) {
|
|
750
750
|
const o = await k({
|
|
751
751
|
...n,
|
|
752
752
|
cacheTime: w
|
|
753
753
|
});
|
|
754
754
|
return n?.accountCap ? e.moveCall({
|
|
755
755
|
target: `${o.package}::lending::exit_emode_with_account_cap`,
|
|
756
|
-
arguments: [e.object(o.storage),
|
|
756
|
+
arguments: [e.object(o.storage), y(n.accountCap, e.object)]
|
|
757
757
|
}) : e.moveCall({
|
|
758
758
|
target: `${o.package}::lending::exit_emode`,
|
|
759
759
|
arguments: [e.object(o.storage)]
|
|
760
760
|
}), e;
|
|
761
761
|
}
|
|
762
|
-
async function
|
|
762
|
+
async function et(e, n, o) {
|
|
763
763
|
const r = await k({
|
|
764
764
|
cacheTime: w,
|
|
765
765
|
...o
|
|
766
766
|
}), t = await _e(e, o);
|
|
767
|
-
await
|
|
767
|
+
await Te(e, n, {
|
|
768
768
|
...o,
|
|
769
769
|
accountCap: t
|
|
770
770
|
});
|
|
771
|
-
const a = await j(o?.market ||
|
|
771
|
+
const a = await j(o?.market || D), i = await je(e, t, o);
|
|
772
772
|
return e.moveCall({
|
|
773
773
|
target: `${r.emode.contract.registryPackage}::registry::register_emode_for_account_cap`,
|
|
774
774
|
arguments: [
|
|
775
775
|
e.object(r.emode.contract.registryObject),
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
776
|
+
i,
|
|
777
|
+
y(a.id, e.pure.u64),
|
|
778
|
+
y(n, e.pure.u64)
|
|
779
779
|
]
|
|
780
780
|
}), t;
|
|
781
781
|
}
|
|
782
|
-
const
|
|
782
|
+
const X = A(
|
|
783
783
|
I(
|
|
784
784
|
async (e, n) => {
|
|
785
785
|
const o = await k({
|
|
786
786
|
cacheTime: w,
|
|
787
787
|
...n
|
|
788
|
-
}), r = new
|
|
788
|
+
}), r = new U(), t = n?.client ?? $;
|
|
789
789
|
r.moveCall({
|
|
790
790
|
target: `${o.emode.contract.registryPackage}::registry::find_user_emode_account_caps`,
|
|
791
791
|
arguments: [r.object(o.emode.contract.registryObject), r.pure.address(e)]
|
|
792
792
|
});
|
|
793
|
-
const
|
|
793
|
+
const i = (await t.devInspectTransactionBlock({
|
|
794
794
|
transactionBlock: r,
|
|
795
795
|
sender: e
|
|
796
|
-
})).results[0].returnValues,
|
|
797
|
-
return
|
|
796
|
+
})).results[0].returnValues, c = C.vector(C.u64()).parse(Uint8Array.from(i[0][0])), s = C.vector(C.u64()).parse(Uint8Array.from(i[1][0])), u = C.vector(C.Address).parse(Uint8Array.from(i[2][0]));
|
|
797
|
+
return c.map((m, d) => ({
|
|
798
798
|
marketId: Number(m),
|
|
799
799
|
emodeId: Number(s[d]),
|
|
800
800
|
accountCap: u[d].toString()
|
|
@@ -802,57 +802,57 @@ const Q = A(
|
|
|
802
802
|
}
|
|
803
803
|
)
|
|
804
804
|
);
|
|
805
|
-
function
|
|
805
|
+
function tt(e) {
|
|
806
806
|
return `${j(e.marketId).key}-${e.emodeId}`;
|
|
807
807
|
}
|
|
808
|
-
function
|
|
808
|
+
function ot(e, n, o) {
|
|
809
809
|
const r = typeof o?.balance == "number", t = r ? o.balance : 0;
|
|
810
810
|
let a = 0;
|
|
811
|
-
const
|
|
812
|
-
let
|
|
811
|
+
const i = [];
|
|
812
|
+
let c = "";
|
|
813
813
|
if (n.sort((s, u) => Number(u.balance) - Number(s.balance)).forEach((s) => {
|
|
814
814
|
if (!(r && a >= t) && Number(s.balance) !== 0) {
|
|
815
|
-
if (
|
|
815
|
+
if (c || (c = s.coinType), c !== s.coinType)
|
|
816
816
|
throw new Error("All coins must be of the same type");
|
|
817
|
-
a += Number(s.balance),
|
|
817
|
+
a += Number(s.balance), i.push(s.coinObjectId);
|
|
818
818
|
}
|
|
819
|
-
}),
|
|
819
|
+
}), i.length === 0)
|
|
820
820
|
throw new Error("No coins to merge");
|
|
821
821
|
if (r && a < t)
|
|
822
822
|
throw new Error(
|
|
823
823
|
`Balance is less than the specified balance: ${a} < ${t}`
|
|
824
824
|
);
|
|
825
|
-
return b(
|
|
825
|
+
return b(c) === b("0x2::sui::SUI") && o?.useGasCoin ? r ? e.splitCoins(e.gas, [e.pure.u64(t)]) : e.gas : (i.length === 1 ? e.object(i[0]) : e.mergeCoins(i[0], i.slice(1)), r ? e.splitCoins(i[0], [e.pure.u64(t)]) : i[0]);
|
|
826
826
|
}
|
|
827
|
-
async function
|
|
828
|
-
const
|
|
829
|
-
...
|
|
827
|
+
async function Z(e, n, o, r, t, a, i) {
|
|
828
|
+
const c = await k({
|
|
829
|
+
...i,
|
|
830
830
|
cacheTime: w
|
|
831
|
-
}), s = await B(o,
|
|
831
|
+
}), s = await B(o, i);
|
|
832
832
|
return e.moveCall({
|
|
833
|
-
target: `${
|
|
833
|
+
target: `${c.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
834
834
|
arguments: [
|
|
835
835
|
e.object("0x06"),
|
|
836
|
-
e.object(
|
|
837
|
-
e.object(
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
836
|
+
e.object(c.storage),
|
|
837
|
+
e.object(c.oracle.priceOracle),
|
|
838
|
+
ve(e, s),
|
|
839
|
+
y(n, e.pure.address),
|
|
840
|
+
y(s.id, e.pure.u8),
|
|
841
|
+
y(r, e.pure.u64),
|
|
842
|
+
y(t, e.pure.u64),
|
|
843
|
+
y(a, e.pure.bool)
|
|
844
844
|
],
|
|
845
845
|
typeArguments: [s.suiCoinType]
|
|
846
846
|
});
|
|
847
847
|
}
|
|
848
|
-
async function
|
|
849
|
-
return
|
|
848
|
+
async function Ie(e, n, o) {
|
|
849
|
+
return Z(e, n, 0, 0, 0, !1, o);
|
|
850
850
|
}
|
|
851
|
-
async function
|
|
852
|
-
const r = new
|
|
851
|
+
async function x(e, n, o) {
|
|
852
|
+
const r = new U(), t = o?.client ?? $, a = await R({
|
|
853
853
|
...o,
|
|
854
854
|
markets: Object.values(E)
|
|
855
|
-
}),
|
|
855
|
+
}), i = q(a);
|
|
856
856
|
for (let m of n) {
|
|
857
857
|
const d = await k({
|
|
858
858
|
...o,
|
|
@@ -867,26 +867,26 @@ async function Z(e, n, o) {
|
|
|
867
867
|
const s = ((await t.devInspectTransactionBlock({
|
|
868
868
|
transactionBlock: r,
|
|
869
869
|
sender: e
|
|
870
|
-
})).results || []).map((m) => m.returnValues?.map((d) =>
|
|
870
|
+
})).results || []).map((m) => m.returnValues?.map((d) => C.vector(de).parse(Uint8Array.from(d[0])))[0] || []), u = [];
|
|
871
871
|
return s.forEach((m, d) => {
|
|
872
872
|
const g = n[d], v = j(g.market);
|
|
873
|
-
m.forEach((
|
|
874
|
-
if (
|
|
873
|
+
m.forEach((f) => {
|
|
874
|
+
if (f.supply_balance === "0" && f.borrow_balance === "0")
|
|
875
875
|
return;
|
|
876
|
-
const h =
|
|
876
|
+
const h = i[`${v.key}-${f.asset_id}`];
|
|
877
877
|
if (!h)
|
|
878
878
|
return;
|
|
879
|
-
const
|
|
880
|
-
|
|
879
|
+
const _ = G(
|
|
880
|
+
f.supply_balance,
|
|
881
881
|
h.currentSupplyIndex
|
|
882
|
-
).toString(), T =
|
|
883
|
-
|
|
882
|
+
).toString(), T = G(
|
|
883
|
+
f.borrow_balance,
|
|
884
884
|
h.currentBorrowIndex
|
|
885
885
|
).toString();
|
|
886
886
|
u.push({
|
|
887
|
-
supplyBalance:
|
|
887
|
+
supplyBalance: _,
|
|
888
888
|
borrowBalance: T,
|
|
889
|
-
assetId:
|
|
889
|
+
assetId: f.asset_id,
|
|
890
890
|
market: v.key,
|
|
891
891
|
pool: h,
|
|
892
892
|
emodeId: g.emodeId
|
|
@@ -894,53 +894,53 @@ async function Z(e, n, o) {
|
|
|
894
894
|
});
|
|
895
895
|
}), u;
|
|
896
896
|
}
|
|
897
|
-
const
|
|
897
|
+
const nt = A(
|
|
898
898
|
async (e, n) => {
|
|
899
899
|
const r = (n?.markets || Object.keys(E)).map((t) => j(t)).map((t) => ({
|
|
900
900
|
address: e,
|
|
901
901
|
market: t.key
|
|
902
902
|
}));
|
|
903
|
-
return await
|
|
903
|
+
return await x(e, r, n);
|
|
904
904
|
}
|
|
905
905
|
);
|
|
906
|
-
async function
|
|
907
|
-
const o = n?.client ?? $, r = new
|
|
908
|
-
await
|
|
906
|
+
async function rt(e, n) {
|
|
907
|
+
const o = n?.client ?? $, r = new U();
|
|
908
|
+
await Ie(r, e, n);
|
|
909
909
|
const t = await o.devInspectTransactionBlock({
|
|
910
910
|
transactionBlock: r,
|
|
911
911
|
sender: e
|
|
912
|
-
}), a =
|
|
913
|
-
return
|
|
912
|
+
}), a = O(t, [C.u256()]);
|
|
913
|
+
return Q(Number(a[0]) || 0);
|
|
914
914
|
}
|
|
915
|
-
async function
|
|
916
|
-
const t = r?.client ?? $, a = new
|
|
917
|
-
let
|
|
915
|
+
async function at(e, n, o, r) {
|
|
916
|
+
const t = r?.client ?? $, a = new U();
|
|
917
|
+
let i = 0, c = 0;
|
|
918
918
|
const s = await B(n, r);
|
|
919
919
|
if (o.forEach((g) => {
|
|
920
|
-
g.type ===
|
|
921
|
-
}),
|
|
920
|
+
g.type === N.Supply ? i += g.amount : g.type === N.Withdraw ? i -= g.amount : g.type === N.Borrow ? c += g.amount : g.type === N.Repay && (c -= g.amount);
|
|
921
|
+
}), i * c < 0)
|
|
922
922
|
throw new Error("Invalid operations");
|
|
923
|
-
const u =
|
|
924
|
-
await
|
|
923
|
+
const u = i > 0 || c > 0;
|
|
924
|
+
await Z(
|
|
925
925
|
a,
|
|
926
926
|
e,
|
|
927
927
|
s,
|
|
928
|
-
Math.abs(c),
|
|
929
928
|
Math.abs(i),
|
|
929
|
+
Math.abs(c),
|
|
930
930
|
u,
|
|
931
931
|
r
|
|
932
932
|
);
|
|
933
933
|
const m = await t.devInspectTransactionBlock({
|
|
934
934
|
transactionBlock: a,
|
|
935
935
|
sender: e
|
|
936
|
-
}), d =
|
|
937
|
-
return
|
|
936
|
+
}), d = O(m, [C.u256()]);
|
|
937
|
+
return Q(Number(d[0]) || 0);
|
|
938
938
|
}
|
|
939
|
-
const
|
|
939
|
+
const ct = I(
|
|
940
940
|
async (e, n) => {
|
|
941
941
|
const o = new URLSearchParams();
|
|
942
942
|
n?.cursor && o.set("cursor", n.cursor), o.set("userAddress", e);
|
|
943
|
-
const r = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${
|
|
943
|
+
const r = `https://open-api.naviprotocol.io/api/navi/user/transactions?${o.toString()}&sdk=${S.version}`;
|
|
944
944
|
return (await fetch(r, { headers: V }).then((a) => a.json())).data;
|
|
945
945
|
}
|
|
946
946
|
);
|
|
@@ -964,86 +964,88 @@ async function it(e, n) {
|
|
|
964
964
|
} while (o);
|
|
965
965
|
return r;
|
|
966
966
|
}
|
|
967
|
-
const
|
|
967
|
+
const Be = A(
|
|
968
968
|
async (e, n) => {
|
|
969
|
-
const o = [], r = (n?.markets || Object.keys(E)).map((
|
|
969
|
+
const o = [], r = (n?.markets || Object.keys(E)).map((c) => j(c)), t = await X(e, n), a = r.map((c) => ({
|
|
970
970
|
address: e,
|
|
971
|
-
market:
|
|
971
|
+
market: c.key
|
|
972
972
|
})).concat(
|
|
973
|
-
t.filter((
|
|
973
|
+
t.filter((c) => !!r.find((s) => s.id === c.marketId)).map((c) => ({
|
|
974
974
|
address: e,
|
|
975
|
-
market: j(
|
|
976
|
-
emodeId:
|
|
975
|
+
market: j(c.marketId).key,
|
|
976
|
+
emodeId: c.emodeId
|
|
977
977
|
}))
|
|
978
978
|
);
|
|
979
|
-
return (await
|
|
980
|
-
const s =
|
|
981
|
-
const m = j(
|
|
982
|
-
return u.emodeId ===
|
|
979
|
+
return (await x(e, a, n)).forEach((c) => {
|
|
980
|
+
const s = c.emodeId ? t.find((u) => {
|
|
981
|
+
const m = j(c.market);
|
|
982
|
+
return u.emodeId === c.emodeId && u.marketId === m.id;
|
|
983
983
|
}) : void 0;
|
|
984
984
|
if (s) {
|
|
985
|
-
if (l(
|
|
986
|
-
const u = l(
|
|
985
|
+
if (l(c.supplyBalance).gt(0)) {
|
|
986
|
+
const u = l(c.supplyBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, l.ROUND_DOWN);
|
|
987
987
|
o.push({
|
|
988
|
-
id: `${
|
|
988
|
+
id: `${c.pool.uniqueId}_${s.emodeId}_navi-lending-emode-supply`,
|
|
989
989
|
wallet: e,
|
|
990
990
|
protocol: "navi",
|
|
991
|
-
market:
|
|
991
|
+
market: c.market,
|
|
992
992
|
type: "navi-lending-emode-supply",
|
|
993
993
|
"navi-lending-emode-supply": {
|
|
994
994
|
amount: u.toString(),
|
|
995
|
-
pool:
|
|
996
|
-
token:
|
|
997
|
-
valueUSD: u.multipliedBy(
|
|
995
|
+
pool: K(c.pool, s),
|
|
996
|
+
token: c.pool.token,
|
|
997
|
+
valueUSD: u.multipliedBy(c.pool.oracle.price).toString(),
|
|
998
|
+
emodeCap: s
|
|
998
999
|
}
|
|
999
1000
|
});
|
|
1000
1001
|
}
|
|
1001
|
-
if (l(
|
|
1002
|
-
const u = l(
|
|
1002
|
+
if (l(c.borrowBalance).gt(0)) {
|
|
1003
|
+
const u = l(c.borrowBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, l.ROUND_DOWN);
|
|
1003
1004
|
o.push({
|
|
1004
|
-
id: `${
|
|
1005
|
+
id: `${c.pool.uniqueId}_${s.emodeId}_navi-lending-emode-borrow`,
|
|
1005
1006
|
wallet: e,
|
|
1006
1007
|
protocol: "navi",
|
|
1007
|
-
market:
|
|
1008
|
+
market: c.market,
|
|
1008
1009
|
type: "navi-lending-emode-borrow",
|
|
1009
1010
|
"navi-lending-emode-borrow": {
|
|
1010
1011
|
amount: u.toString(),
|
|
1011
|
-
pool:
|
|
1012
|
-
token:
|
|
1013
|
-
valueUSD: u.multipliedBy(
|
|
1012
|
+
pool: K(c.pool, s),
|
|
1013
|
+
token: c.pool.token,
|
|
1014
|
+
valueUSD: u.multipliedBy(c.pool.oracle.price).toString(),
|
|
1015
|
+
emodeCap: s
|
|
1014
1016
|
}
|
|
1015
1017
|
});
|
|
1016
1018
|
}
|
|
1017
1019
|
} else {
|
|
1018
|
-
if (l(
|
|
1019
|
-
const u = l(
|
|
1020
|
+
if (l(c.supplyBalance).gt(0)) {
|
|
1021
|
+
const u = l(c.supplyBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, l.ROUND_DOWN);
|
|
1020
1022
|
o.push({
|
|
1021
|
-
id: `${
|
|
1023
|
+
id: `${c.pool.uniqueId}_navi-lending-supply`,
|
|
1022
1024
|
wallet: e,
|
|
1023
1025
|
protocol: "navi",
|
|
1024
1026
|
type: "navi-lending-supply",
|
|
1025
|
-
market:
|
|
1027
|
+
market: c.market,
|
|
1026
1028
|
"navi-lending-supply": {
|
|
1027
1029
|
amount: u.toString(),
|
|
1028
|
-
pool:
|
|
1029
|
-
token:
|
|
1030
|
-
valueUSD: u.multipliedBy(
|
|
1030
|
+
pool: c.pool,
|
|
1031
|
+
token: c.pool.token,
|
|
1032
|
+
valueUSD: u.multipliedBy(c.pool.oracle.price).toString()
|
|
1031
1033
|
}
|
|
1032
1034
|
});
|
|
1033
1035
|
}
|
|
1034
|
-
if (l(
|
|
1035
|
-
const u = l(
|
|
1036
|
+
if (l(c.borrowBalance).gt(0)) {
|
|
1037
|
+
const u = l(c.borrowBalance).shiftedBy(-9).decimalPlaces(c.pool.token.decimals, l.ROUND_DOWN);
|
|
1036
1038
|
o.push({
|
|
1037
|
-
id: `${
|
|
1039
|
+
id: `${c.pool.uniqueId}_navi-lending-borrow`,
|
|
1038
1040
|
wallet: e,
|
|
1039
1041
|
protocol: "navi",
|
|
1040
|
-
market:
|
|
1042
|
+
market: c.market,
|
|
1041
1043
|
type: "navi-lending-borrow",
|
|
1042
1044
|
"navi-lending-borrow": {
|
|
1043
1045
|
amount: u.toString(),
|
|
1044
|
-
pool:
|
|
1045
|
-
token:
|
|
1046
|
-
valueUSD: u.multipliedBy(
|
|
1046
|
+
pool: c.pool,
|
|
1047
|
+
token: c.pool.token,
|
|
1048
|
+
valueUSD: u.multipliedBy(c.pool.oracle.price).toString()
|
|
1047
1049
|
}
|
|
1048
1050
|
});
|
|
1049
1051
|
}
|
|
@@ -1051,7 +1053,7 @@ const Ie = A(
|
|
|
1051
1053
|
}), o;
|
|
1052
1054
|
}
|
|
1053
1055
|
);
|
|
1054
|
-
class
|
|
1056
|
+
class M {
|
|
1055
1057
|
constructor(n) {
|
|
1056
1058
|
this._positions = [], this._overview = {
|
|
1057
1059
|
hf: 1 / 0,
|
|
@@ -1074,11 +1076,18 @@ class ct {
|
|
|
1074
1076
|
set positions(n) {
|
|
1075
1077
|
this._positions = n, this._overview = this.getPositionsOverview(n);
|
|
1076
1078
|
}
|
|
1079
|
+
filterPositionsByPool(n) {
|
|
1080
|
+
const r = !!n.isEMode ? ["navi-lending-emode-supply", "navi-lending-emode-borrow"] : ["navi-lending-supply", "navi-lending-borrow"];
|
|
1081
|
+
return new M(this.positions.filter((t) => {
|
|
1082
|
+
const a = t[t.type];
|
|
1083
|
+
return r.includes(t.type) && a.pool.uniqueId === n.uniqueId;
|
|
1084
|
+
}));
|
|
1085
|
+
}
|
|
1077
1086
|
deposit(n, o) {
|
|
1078
1087
|
const r = !!n.isEMode;
|
|
1079
1088
|
let t;
|
|
1080
|
-
r ? t = {
|
|
1081
|
-
id:
|
|
1089
|
+
return r ? t = {
|
|
1090
|
+
id: P(),
|
|
1082
1091
|
wallet: "",
|
|
1083
1092
|
protocol: "navi",
|
|
1084
1093
|
market: "",
|
|
@@ -1087,10 +1096,11 @@ class ct {
|
|
|
1087
1096
|
amount: o.toString(),
|
|
1088
1097
|
valueUSD: l(o).multipliedBy(n.oracle.price).toString(),
|
|
1089
1098
|
token: n.token,
|
|
1090
|
-
pool: n
|
|
1099
|
+
pool: n,
|
|
1100
|
+
emodeCap: {}
|
|
1091
1101
|
}
|
|
1092
1102
|
} : t = {
|
|
1093
|
-
id:
|
|
1103
|
+
id: P(),
|
|
1094
1104
|
wallet: "",
|
|
1095
1105
|
protocol: "navi",
|
|
1096
1106
|
market: "",
|
|
@@ -1101,13 +1111,13 @@ class ct {
|
|
|
1101
1111
|
token: n.token,
|
|
1102
1112
|
pool: n
|
|
1103
1113
|
}
|
|
1104
|
-
},
|
|
1114
|
+
}, new M([...this.positions, t]);
|
|
1105
1115
|
}
|
|
1106
1116
|
withdraw(n, o) {
|
|
1107
1117
|
const r = !!n.isEMode;
|
|
1108
1118
|
let t;
|
|
1109
|
-
r ? t = {
|
|
1110
|
-
id:
|
|
1119
|
+
return r ? t = {
|
|
1120
|
+
id: P(),
|
|
1111
1121
|
wallet: "",
|
|
1112
1122
|
protocol: "navi",
|
|
1113
1123
|
market: "",
|
|
@@ -1116,10 +1126,11 @@ class ct {
|
|
|
1116
1126
|
amount: (-o).toString(),
|
|
1117
1127
|
valueUSD: l(-o).multipliedBy(n.oracle.price).toString(),
|
|
1118
1128
|
token: n.token,
|
|
1119
|
-
pool: n
|
|
1129
|
+
pool: n,
|
|
1130
|
+
emodeCap: {}
|
|
1120
1131
|
}
|
|
1121
1132
|
} : t = {
|
|
1122
|
-
id:
|
|
1133
|
+
id: P(),
|
|
1123
1134
|
wallet: "",
|
|
1124
1135
|
protocol: "navi",
|
|
1125
1136
|
market: "",
|
|
@@ -1130,13 +1141,13 @@ class ct {
|
|
|
1130
1141
|
token: n.token,
|
|
1131
1142
|
pool: n
|
|
1132
1143
|
}
|
|
1133
|
-
},
|
|
1144
|
+
}, new M([...this.positions, t]);
|
|
1134
1145
|
}
|
|
1135
1146
|
borrow(n, o) {
|
|
1136
1147
|
const r = !!n.isEMode;
|
|
1137
1148
|
let t;
|
|
1138
|
-
r ? t = {
|
|
1139
|
-
id:
|
|
1149
|
+
return r ? t = {
|
|
1150
|
+
id: P(),
|
|
1140
1151
|
wallet: "",
|
|
1141
1152
|
protocol: "navi",
|
|
1142
1153
|
market: "",
|
|
@@ -1145,10 +1156,11 @@ class ct {
|
|
|
1145
1156
|
amount: o.toString(),
|
|
1146
1157
|
valueUSD: l(o).multipliedBy(n.oracle.price).toString(),
|
|
1147
1158
|
token: n.token,
|
|
1148
|
-
pool: n
|
|
1159
|
+
pool: n,
|
|
1160
|
+
emodeCap: {}
|
|
1149
1161
|
}
|
|
1150
1162
|
} : t = {
|
|
1151
|
-
id:
|
|
1163
|
+
id: P(),
|
|
1152
1164
|
wallet: "",
|
|
1153
1165
|
protocol: "navi",
|
|
1154
1166
|
market: "",
|
|
@@ -1159,13 +1171,13 @@ class ct {
|
|
|
1159
1171
|
token: n.token,
|
|
1160
1172
|
pool: n
|
|
1161
1173
|
}
|
|
1162
|
-
},
|
|
1174
|
+
}, new M([...this.positions, t]);
|
|
1163
1175
|
}
|
|
1164
1176
|
repay(n, o) {
|
|
1165
1177
|
const r = !!n.isEMode;
|
|
1166
1178
|
let t;
|
|
1167
|
-
r ? t = {
|
|
1168
|
-
id:
|
|
1179
|
+
return r ? t = {
|
|
1180
|
+
id: P(),
|
|
1169
1181
|
wallet: "",
|
|
1170
1182
|
protocol: "navi",
|
|
1171
1183
|
market: "",
|
|
@@ -1174,10 +1186,11 @@ class ct {
|
|
|
1174
1186
|
amount: (-o).toString(),
|
|
1175
1187
|
valueUSD: l(-o).multipliedBy(n.oracle.price).toString(),
|
|
1176
1188
|
token: n.token,
|
|
1177
|
-
pool: n
|
|
1189
|
+
pool: n,
|
|
1190
|
+
emodeCap: {}
|
|
1178
1191
|
}
|
|
1179
1192
|
} : t = {
|
|
1180
|
-
id:
|
|
1193
|
+
id: P(),
|
|
1181
1194
|
wallet: "",
|
|
1182
1195
|
protocol: "navi",
|
|
1183
1196
|
market: "",
|
|
@@ -1188,20 +1201,16 @@ class ct {
|
|
|
1188
1201
|
token: n.token,
|
|
1189
1202
|
pool: n
|
|
1190
1203
|
}
|
|
1191
|
-
},
|
|
1192
|
-
}
|
|
1193
|
-
findPositionsByPool(n, o) {
|
|
1194
|
-
const r = !!n.isEMode;
|
|
1195
|
-
return this.positions.filter((t) => r ? t.type === (o ? "navi-lending-emode-supply" : "navi-lending-emode-borrow") : t.type === (o ? "navi-lending-supply" : "navi-lending-borrow"));
|
|
1204
|
+
}, new M([...this.positions, t]);
|
|
1196
1205
|
}
|
|
1197
1206
|
getPositionsOverview(n) {
|
|
1198
|
-
let o = new l(0), r = new l(0), t = new l(0), a = new l(0),
|
|
1207
|
+
let o = new l(0), r = new l(0), t = new l(0), a = new l(0), i = new l(0), c = new l(0);
|
|
1199
1208
|
n.forEach((d) => {
|
|
1200
1209
|
if (d.type === "navi-lending-supply") {
|
|
1201
1210
|
const g = d["navi-lending-supply"];
|
|
1202
|
-
o = o.plus(g.valueUSD),
|
|
1211
|
+
o = o.plus(g.valueUSD), i = i.plus(
|
|
1203
1212
|
new l(g.valueUSD).multipliedBy(g.pool.liquidationFactor.threshold)
|
|
1204
|
-
),
|
|
1213
|
+
), c = c.plus(
|
|
1205
1214
|
new l(g.valueUSD).multipliedBy(g.pool.ltvValue)
|
|
1206
1215
|
);
|
|
1207
1216
|
} else if (d.type === "navi-lending-borrow")
|
|
@@ -1210,9 +1219,9 @@ class ct {
|
|
|
1210
1219
|
const g = d["navi-lending-emode-supply"];
|
|
1211
1220
|
o = o.plus(g.valueUSD);
|
|
1212
1221
|
const v = g.pool.emode;
|
|
1213
|
-
|
|
1222
|
+
i = i.plus(
|
|
1214
1223
|
new l(g.valueUSD).multipliedBy(v.lt)
|
|
1215
|
-
),
|
|
1224
|
+
), c = c.plus(
|
|
1216
1225
|
new l(g.valueUSD).multipliedBy(v.ltv)
|
|
1217
1226
|
);
|
|
1218
1227
|
} else d.type === "navi-lending-emode-borrow" && (r = r.plus(d["navi-lending-emode-borrow"].valueUSD));
|
|
@@ -1241,24 +1250,24 @@ class ct {
|
|
|
1241
1250
|
});
|
|
1242
1251
|
const s = o.minus(r), u = o.minus(r).eq(0) ? new l(0) : o.multipliedBy(t).minus(r.multipliedBy(a)).div(o.minus(r));
|
|
1243
1252
|
return {
|
|
1244
|
-
hf: r.toNumber() !== 0 ?
|
|
1253
|
+
hf: r.toNumber() !== 0 ? i.dividedBy(r).toNumber() : 1 / 0,
|
|
1245
1254
|
netVaule: s.toString(),
|
|
1246
1255
|
netWorthApr: u.toString(),
|
|
1247
1256
|
totalSupplyValue: o.toString(),
|
|
1248
1257
|
totalBorrowValue: r.toString(),
|
|
1249
1258
|
totalsupplyApy: t.toString(),
|
|
1250
1259
|
totalBorrowApy: a.toString(),
|
|
1251
|
-
maxLiquidationValue:
|
|
1252
|
-
maxLoanToVaule:
|
|
1260
|
+
maxLiquidationValue: i.toString(),
|
|
1261
|
+
maxLoanToVaule: c.toString()
|
|
1253
1262
|
};
|
|
1254
1263
|
}
|
|
1255
1264
|
}
|
|
1256
|
-
const
|
|
1265
|
+
const ee = new Y("https://hermes.pyth.network", {
|
|
1257
1266
|
timeout: 1e4
|
|
1258
1267
|
});
|
|
1259
|
-
async function
|
|
1268
|
+
async function Ae(e) {
|
|
1260
1269
|
try {
|
|
1261
|
-
const n = [], o = await
|
|
1270
|
+
const n = [], o = await ee.getLatestPriceFeeds(e);
|
|
1262
1271
|
if (!o) return n;
|
|
1263
1272
|
const r = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
1264
1273
|
for (const t of o) {
|
|
@@ -1278,14 +1287,14 @@ async function Be(e) {
|
|
|
1278
1287
|
throw new Error(`failed to get pyth stale price feed id, msg: ${n.message}`);
|
|
1279
1288
|
}
|
|
1280
1289
|
}
|
|
1281
|
-
async function
|
|
1290
|
+
async function $e(e, n, o) {
|
|
1282
1291
|
const r = o?.client ?? $, t = await k({
|
|
1283
1292
|
...o,
|
|
1284
1293
|
cacheTime: w
|
|
1285
1294
|
});
|
|
1286
1295
|
try {
|
|
1287
|
-
const a = await
|
|
1288
|
-
return await new
|
|
1296
|
+
const a = await ee.getPriceFeedsUpdateData(n);
|
|
1297
|
+
return await new le(
|
|
1289
1298
|
r,
|
|
1290
1299
|
t.oracle.pythStateId,
|
|
1291
1300
|
t.oracle.wormholeStateId
|
|
@@ -1294,7 +1303,7 @@ async function Ae(e, n, o) {
|
|
|
1294
1303
|
throw new Error(`failed to update pyth price feeds, msg: ${a.message}`);
|
|
1295
1304
|
}
|
|
1296
1305
|
}
|
|
1297
|
-
async function
|
|
1306
|
+
async function Se(e, n, o) {
|
|
1298
1307
|
const r = await k({
|
|
1299
1308
|
...o,
|
|
1300
1309
|
cacheTime: w
|
|
@@ -1302,8 +1311,8 @@ async function $e(e, n, o) {
|
|
|
1302
1311
|
if (o?.updatePythPriceFeeds) {
|
|
1303
1312
|
const t = n.filter((a) => !!a.pythPriceFeedId).map((a) => a.pythPriceFeedId);
|
|
1304
1313
|
try {
|
|
1305
|
-
const a = await
|
|
1306
|
-
a.length > 0 && await
|
|
1314
|
+
const a = await Ae(t);
|
|
1315
|
+
a.length > 0 && await $e(e, a, o);
|
|
1307
1316
|
} catch {
|
|
1308
1317
|
}
|
|
1309
1318
|
}
|
|
@@ -1327,7 +1336,7 @@ async function $e(e, n, o) {
|
|
|
1327
1336
|
});
|
|
1328
1337
|
return e;
|
|
1329
1338
|
}
|
|
1330
|
-
async function
|
|
1339
|
+
async function te(e) {
|
|
1331
1340
|
return (await k({
|
|
1332
1341
|
...e,
|
|
1333
1342
|
cacheTime: w
|
|
@@ -1343,20 +1352,20 @@ function Pe(e, n) {
|
|
|
1343
1352
|
}
|
|
1344
1353
|
async function st(e, n, o, r) {
|
|
1345
1354
|
try {
|
|
1346
|
-
const t = await
|
|
1355
|
+
const t = await te({
|
|
1347
1356
|
...r
|
|
1348
1357
|
}), a = [];
|
|
1349
1358
|
o.forEach((u) => {
|
|
1350
1359
|
a.includes(u.market) || a.push(u.market);
|
|
1351
1360
|
});
|
|
1352
|
-
const
|
|
1361
|
+
const i = await Be(n, {
|
|
1353
1362
|
...r,
|
|
1354
1363
|
markets: a
|
|
1355
|
-
}),
|
|
1356
|
-
lendingPositions:
|
|
1364
|
+
}), c = Pe(t, {
|
|
1365
|
+
lendingPositions: i,
|
|
1357
1366
|
pools: o
|
|
1358
1367
|
});
|
|
1359
|
-
return await
|
|
1368
|
+
return await Se(e, c, {
|
|
1360
1369
|
updatePythPriceFeeds: !0,
|
|
1361
1370
|
...r
|
|
1362
1371
|
});
|
|
@@ -1369,7 +1378,7 @@ async function st(e, n, o, r) {
|
|
|
1369
1378
|
const L = A(
|
|
1370
1379
|
I(
|
|
1371
1380
|
async (e) => {
|
|
1372
|
-
const n = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${e?.env || "prod"}&sdk=${
|
|
1381
|
+
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: V }).then((r) => r.json());
|
|
1373
1382
|
return Object.keys(o.data).map((r) => ({
|
|
1374
1383
|
...o.data[r],
|
|
1375
1384
|
coinType: r
|
|
@@ -1398,7 +1407,7 @@ async function lt(e, n, o, r) {
|
|
|
1398
1407
|
arguments: [
|
|
1399
1408
|
e.object(t.flashloanConfig),
|
|
1400
1409
|
e.object(a.contract.pool),
|
|
1401
|
-
|
|
1410
|
+
y(o, e.pure.u64)
|
|
1402
1411
|
],
|
|
1403
1412
|
typeArguments: [a.suiCoinType]
|
|
1404
1413
|
});
|
|
@@ -1409,7 +1418,7 @@ async function lt(e, n, o, r) {
|
|
|
1409
1418
|
arguments: [
|
|
1410
1419
|
e.object(t.flashloanConfig),
|
|
1411
1420
|
e.object(a.contract.pool),
|
|
1412
|
-
|
|
1421
|
+
y(o, e.pure.u64),
|
|
1413
1422
|
e.object("0x05")
|
|
1414
1423
|
],
|
|
1415
1424
|
typeArguments: [a.suiCoinType]
|
|
@@ -1421,12 +1430,12 @@ async function pt(e, n, o, r, t) {
|
|
|
1421
1430
|
const a = await k({
|
|
1422
1431
|
...t,
|
|
1423
1432
|
cacheTime: w
|
|
1424
|
-
}),
|
|
1433
|
+
}), i = await B(n, t);
|
|
1425
1434
|
if (!(await L({
|
|
1426
1435
|
...t,
|
|
1427
1436
|
cacheTime: w
|
|
1428
1437
|
})).some(
|
|
1429
|
-
(m) => b(m.coinType) === b(
|
|
1438
|
+
(m) => b(m.coinType) === b(i.suiCoinType)
|
|
1430
1439
|
))
|
|
1431
1440
|
throw new Error("Pool does not support flashloan");
|
|
1432
1441
|
const [u] = e.moveCall({
|
|
@@ -1434,44 +1443,44 @@ async function pt(e, n, o, r, t) {
|
|
|
1434
1443
|
arguments: [
|
|
1435
1444
|
e.object("0x06"),
|
|
1436
1445
|
e.object(a.storage),
|
|
1437
|
-
e.object(
|
|
1438
|
-
|
|
1439
|
-
|
|
1446
|
+
e.object(i.contract.pool),
|
|
1447
|
+
y(o, e.object),
|
|
1448
|
+
y(r, e.object)
|
|
1440
1449
|
],
|
|
1441
|
-
typeArguments: [
|
|
1450
|
+
typeArguments: [i.suiCoinType]
|
|
1442
1451
|
});
|
|
1443
1452
|
return [u];
|
|
1444
1453
|
}
|
|
1445
1454
|
async function dt(e, n, o, r, t, a) {
|
|
1446
|
-
const
|
|
1455
|
+
const i = {
|
|
1447
1456
|
...a,
|
|
1448
1457
|
cacheTime: w
|
|
1449
|
-
},
|
|
1450
|
-
if (
|
|
1458
|
+
}, c = await k(i), s = await B(n, i), u = await B(r, i);
|
|
1459
|
+
if (c.version === 1) {
|
|
1451
1460
|
const [m, d] = e.moveCall({
|
|
1452
|
-
target: `${
|
|
1461
|
+
target: `${c.package}::incentive_v3::liquidation`,
|
|
1453
1462
|
arguments: [
|
|
1454
1463
|
e.object("0x06"),
|
|
1455
1464
|
// Clock object
|
|
1456
|
-
e.object(
|
|
1465
|
+
e.object(c.priceOracle),
|
|
1457
1466
|
// Price oracle for asset pricing
|
|
1458
|
-
e.object(
|
|
1467
|
+
e.object(c.storage),
|
|
1459
1468
|
// Protocol storage
|
|
1460
1469
|
e.pure.u8(s.id),
|
|
1461
1470
|
// Pay asset ID
|
|
1462
1471
|
e.object(s.contract.pool),
|
|
1463
1472
|
// Pay asset pool contract
|
|
1464
|
-
|
|
1473
|
+
y(o, e.object),
|
|
1465
1474
|
// Debt repayment amount
|
|
1466
1475
|
e.pure.u8(u.id),
|
|
1467
1476
|
// Collateral asset ID
|
|
1468
1477
|
e.object(u.contract.pool),
|
|
1469
1478
|
// Collateral asset pool contract
|
|
1470
|
-
|
|
1479
|
+
y(t, e.pure.address),
|
|
1471
1480
|
// Borrower address
|
|
1472
|
-
e.object(
|
|
1481
|
+
e.object(c.incentiveV2),
|
|
1473
1482
|
// Incentive V2 contract
|
|
1474
|
-
e.object(
|
|
1483
|
+
e.object(c.incentiveV3)
|
|
1475
1484
|
// Incentive V3 contract
|
|
1476
1485
|
],
|
|
1477
1486
|
typeArguments: [s.suiCoinType, u.suiCoinType]
|
|
@@ -1479,29 +1488,29 @@ async function dt(e, n, o, r, t, a) {
|
|
|
1479
1488
|
return [m, d];
|
|
1480
1489
|
} else {
|
|
1481
1490
|
const [m, d] = e.moveCall({
|
|
1482
|
-
target: `${
|
|
1491
|
+
target: `${c.package}::incentive_v3::liquidation_v2`,
|
|
1483
1492
|
arguments: [
|
|
1484
1493
|
e.object("0x06"),
|
|
1485
1494
|
// Clock object
|
|
1486
|
-
e.object(
|
|
1495
|
+
e.object(c.priceOracle),
|
|
1487
1496
|
// Price oracle for asset pricing
|
|
1488
|
-
e.object(
|
|
1497
|
+
e.object(c.storage),
|
|
1489
1498
|
// Protocol storage
|
|
1490
1499
|
e.pure.u8(s.id),
|
|
1491
1500
|
// Pay asset ID
|
|
1492
1501
|
e.object(s.contract.pool),
|
|
1493
1502
|
// Pay asset pool contract
|
|
1494
|
-
|
|
1503
|
+
y(o, e.object),
|
|
1495
1504
|
// Debt repayment amount
|
|
1496
1505
|
e.pure.u8(u.id),
|
|
1497
1506
|
// Collateral asset ID
|
|
1498
1507
|
e.object(u.contract.pool),
|
|
1499
1508
|
// Collateral asset pool contract
|
|
1500
|
-
|
|
1509
|
+
y(t, e.pure.address),
|
|
1501
1510
|
// Borrower address
|
|
1502
|
-
e.object(
|
|
1511
|
+
e.object(c.incentiveV2),
|
|
1503
1512
|
// Incentive V2 contract
|
|
1504
|
-
e.object(
|
|
1513
|
+
e.object(c.incentiveV3),
|
|
1505
1514
|
// Incentive V3 contract
|
|
1506
1515
|
e.object("0x05")
|
|
1507
1516
|
// SuiSystemState object
|
|
@@ -1511,12 +1520,12 @@ async function dt(e, n, o, r, t, a) {
|
|
|
1511
1520
|
return [m, d];
|
|
1512
1521
|
}
|
|
1513
1522
|
}
|
|
1514
|
-
async function
|
|
1515
|
-
const r = o?.client ?? $, t = new
|
|
1523
|
+
async function Ve(e, n, o) {
|
|
1524
|
+
const r = o?.client ?? $, t = new U(), a = await R({
|
|
1516
1525
|
...o,
|
|
1517
1526
|
markets: Object.values(E),
|
|
1518
1527
|
cacheTime: w
|
|
1519
|
-
}),
|
|
1528
|
+
}), i = await te(o);
|
|
1520
1529
|
for (let m of n) {
|
|
1521
1530
|
const d = await k({
|
|
1522
1531
|
...o,
|
|
@@ -1537,26 +1546,26 @@ async function Se(e, n, o) {
|
|
|
1537
1546
|
]
|
|
1538
1547
|
});
|
|
1539
1548
|
}
|
|
1540
|
-
const
|
|
1549
|
+
const c = await r.devInspectTransactionBlock({
|
|
1541
1550
|
transactionBlock: t,
|
|
1542
1551
|
sender: e
|
|
1543
1552
|
}), s = [];
|
|
1544
|
-
|
|
1553
|
+
c?.results?.forEach((m) => {
|
|
1545
1554
|
s.push(
|
|
1546
|
-
|
|
1555
|
+
O(
|
|
1547
1556
|
{
|
|
1548
1557
|
results: [m]
|
|
1549
1558
|
},
|
|
1550
1559
|
[
|
|
1551
|
-
|
|
1560
|
+
C.vector(C.string()),
|
|
1552
1561
|
// Asset coin types
|
|
1553
|
-
|
|
1562
|
+
C.vector(C.string()),
|
|
1554
1563
|
// Reward coin types
|
|
1555
|
-
|
|
1564
|
+
C.vector(C.u8()),
|
|
1556
1565
|
// Reward options
|
|
1557
|
-
|
|
1566
|
+
C.vector(C.Address),
|
|
1558
1567
|
// Rule IDs
|
|
1559
|
-
|
|
1568
|
+
C.vector(C.u256())
|
|
1560
1569
|
// Claimable amounts
|
|
1561
1570
|
]
|
|
1562
1571
|
)
|
|
@@ -1567,19 +1576,19 @@ async function Se(e, n, o) {
|
|
|
1567
1576
|
const g = n[d];
|
|
1568
1577
|
if (m.length === 5 && Array.isArray(m[0])) {
|
|
1569
1578
|
const v = m[0].length;
|
|
1570
|
-
for (let
|
|
1571
|
-
const h =
|
|
1572
|
-
(T) => b(T.coinType) === b(m[1][
|
|
1573
|
-
),
|
|
1574
|
-
(T) => b(T.coinType) === b(m[0][
|
|
1579
|
+
for (let f = 0; f < v; f++) {
|
|
1580
|
+
const h = i.find(
|
|
1581
|
+
(T) => b(T.coinType) === b(m[1][f])
|
|
1582
|
+
), _ = a.find(
|
|
1583
|
+
(T) => b(T.coinType) === b(m[0][f])
|
|
1575
1584
|
);
|
|
1576
|
-
!h || !
|
|
1577
|
-
assetId:
|
|
1578
|
-
assetCoinType: b(m[0][
|
|
1579
|
-
rewardCoinType: b(m[1][
|
|
1580
|
-
option: Number(m[2][
|
|
1581
|
-
userClaimableReward: Number(m[4][
|
|
1582
|
-
ruleIds: Array.isArray(m[3][
|
|
1585
|
+
!h || !_ || u.push({
|
|
1586
|
+
assetId: _.id,
|
|
1587
|
+
assetCoinType: b(m[0][f]),
|
|
1588
|
+
rewardCoinType: b(m[1][f]),
|
|
1589
|
+
option: Number(m[2][f]),
|
|
1590
|
+
userClaimableReward: Number(m[4][f]) / Math.pow(10, h.priceDecimal),
|
|
1591
|
+
ruleIds: Array.isArray(m[3][f]) ? m[3][f] : [m[3][f]],
|
|
1583
1592
|
market: g.market,
|
|
1584
1593
|
owner: g.address,
|
|
1585
1594
|
emodeId: g.emodeId
|
|
@@ -1589,26 +1598,26 @@ async function Se(e, n, o) {
|
|
|
1589
1598
|
}), u;
|
|
1590
1599
|
}
|
|
1591
1600
|
async function mt(e, n) {
|
|
1592
|
-
const o = (n?.markets || [E.main]).map((a) => j(a)), r = await
|
|
1601
|
+
const o = (n?.markets || [E.main]).map((a) => j(a)), r = await X(e, n), t = o.map((a) => ({
|
|
1593
1602
|
address: e,
|
|
1594
1603
|
market: a.key
|
|
1595
1604
|
})).concat(
|
|
1596
|
-
r.filter((a) => !!o.find((
|
|
1597
|
-
const
|
|
1605
|
+
r.filter((a) => !!o.find((i) => i.id === a.marketId)).map((a) => {
|
|
1606
|
+
const i = j(a.marketId);
|
|
1598
1607
|
return {
|
|
1599
1608
|
address: e,
|
|
1600
|
-
market:
|
|
1609
|
+
market: i.key,
|
|
1601
1610
|
emodeId: a.emodeId
|
|
1602
1611
|
};
|
|
1603
1612
|
})
|
|
1604
1613
|
);
|
|
1605
|
-
return await
|
|
1614
|
+
return await Ve(e, t, n);
|
|
1606
1615
|
}
|
|
1607
1616
|
function gt(e) {
|
|
1608
1617
|
const n = /* @__PURE__ */ new Map();
|
|
1609
1618
|
e.forEach((r) => {
|
|
1610
|
-
const t = r.assetId, a = r.option,
|
|
1611
|
-
n.has(
|
|
1619
|
+
const t = r.assetId, a = r.option, i = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
|
|
1620
|
+
n.has(i) ? n.get(i).total += r.userClaimableReward : n.set(i, {
|
|
1612
1621
|
assetId: t,
|
|
1613
1622
|
rewardType: a,
|
|
1614
1623
|
coinType: r.rewardCoinType,
|
|
@@ -1617,11 +1626,11 @@ function gt(e) {
|
|
|
1617
1626
|
});
|
|
1618
1627
|
});
|
|
1619
1628
|
const o = /* @__PURE__ */ new Map();
|
|
1620
|
-
for (const { assetId: r, rewardType: t, coinType: a, total:
|
|
1621
|
-
const s = `${r}-${t}-${
|
|
1622
|
-
o.has(s) || o.set(s, { assetId: r, rewardType: t, market:
|
|
1629
|
+
for (const { assetId: r, rewardType: t, coinType: a, total: i, market: c } of n.values()) {
|
|
1630
|
+
const s = `${r}-${t}-${c}`;
|
|
1631
|
+
o.has(s) || o.set(s, { assetId: r, rewardType: t, market: c, rewards: /* @__PURE__ */ new Map() });
|
|
1623
1632
|
const u = o.get(s);
|
|
1624
|
-
u.rewards.set(a, (u.rewards.get(a) || 0) +
|
|
1633
|
+
u.rewards.set(a, (u.rewards.get(a) || 0) + i);
|
|
1625
1634
|
}
|
|
1626
1635
|
return Array.from(o.values()).map((r) => ({
|
|
1627
1636
|
assetId: r.assetId,
|
|
@@ -1633,15 +1642,15 @@ function gt(e) {
|
|
|
1633
1642
|
}))
|
|
1634
1643
|
}));
|
|
1635
1644
|
}
|
|
1636
|
-
const
|
|
1645
|
+
const yt = I(
|
|
1637
1646
|
async (e, n) => {
|
|
1638
|
-
const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${
|
|
1647
|
+
const o = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}&sdk=${S.version}&market=${n?.market || D}`;
|
|
1639
1648
|
return (await fetch(o, { headers: V }).then((t) => t.json())).data;
|
|
1640
1649
|
}
|
|
1641
|
-
),
|
|
1650
|
+
), ft = I(
|
|
1642
1651
|
async (e, n) => {
|
|
1643
|
-
const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${n?.page || 1}&pageSize=${n?.size || 400}&sdk=${
|
|
1644
|
-
return
|
|
1652
|
+
const o = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${n?.page || 1}&pageSize=${n?.size || 400}&sdk=${S.version}&market=${n?.market || D}`, r = await fetch(o, { headers: V }).then((t) => t.json());
|
|
1653
|
+
return F({
|
|
1645
1654
|
data: r.data.rewards
|
|
1646
1655
|
});
|
|
1647
1656
|
}
|
|
@@ -1650,14 +1659,14 @@ async function vt(e, n, o) {
|
|
|
1650
1659
|
const r = await k({
|
|
1651
1660
|
...o,
|
|
1652
1661
|
cacheTime: w
|
|
1653
|
-
}), t = await
|
|
1662
|
+
}), t = await R({
|
|
1654
1663
|
...o,
|
|
1655
1664
|
markets: Object.values(E),
|
|
1656
1665
|
cacheTime: w
|
|
1657
1666
|
}), a = /* @__PURE__ */ new Map();
|
|
1658
|
-
for (const
|
|
1659
|
-
const { rewardCoinType: s, ruleIds: u, market: m, owner: d, emodeId: g } =
|
|
1660
|
-
for (const
|
|
1667
|
+
for (const c of n) {
|
|
1668
|
+
const { rewardCoinType: s, ruleIds: u, market: m, owner: d, emodeId: g } = c, v = `${s}-${m}-${d}`;
|
|
1669
|
+
for (const f of u) {
|
|
1661
1670
|
a.has(v) || a.set(v, {
|
|
1662
1671
|
assetIds: [],
|
|
1663
1672
|
ruleIds: [],
|
|
@@ -1667,22 +1676,22 @@ async function vt(e, n, o) {
|
|
|
1667
1676
|
isEMode: typeof g < "u"
|
|
1668
1677
|
});
|
|
1669
1678
|
const h = a.get(v);
|
|
1670
|
-
h.assetIds.push(
|
|
1679
|
+
h.assetIds.push(c.assetCoinType.replace("0x", "")), h.ruleIds.push(f), h.amount += c.userClaimableReward;
|
|
1671
1680
|
}
|
|
1672
1681
|
}
|
|
1673
|
-
const
|
|
1674
|
-
for (const [
|
|
1675
|
-
const
|
|
1676
|
-
(
|
|
1682
|
+
const i = [];
|
|
1683
|
+
for (const [c, { assetIds: s, ruleIds: u, amount: m, market: d, owner: g, isEMode: v }] of a) {
|
|
1684
|
+
const f = t.find(
|
|
1685
|
+
(_) => b(_.suiCoinType) === b(c) && _.market === d
|
|
1677
1686
|
);
|
|
1678
|
-
if (!
|
|
1679
|
-
throw new Error(`No matching rewardFund found for reward coin: ${
|
|
1680
|
-
const h =
|
|
1687
|
+
if (!f || !f.contract.rewardFundId)
|
|
1688
|
+
throw new Error(`No matching rewardFund found for reward coin: ${c} ${d}`);
|
|
1689
|
+
const h = f.contract.rewardFundId;
|
|
1681
1690
|
if (o?.accountCap && !o.customCoinReceive)
|
|
1682
1691
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
1683
1692
|
if (o?.customCoinReceive) {
|
|
1684
|
-
let
|
|
1685
|
-
o.accountCap ?
|
|
1693
|
+
let _;
|
|
1694
|
+
o.accountCap ? _ = e.moveCall({
|
|
1686
1695
|
target: `${r.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1687
1696
|
arguments: [
|
|
1688
1697
|
e.object("0x06"),
|
|
@@ -1697,11 +1706,11 @@ async function vt(e, n, o) {
|
|
|
1697
1706
|
// Asset IDs
|
|
1698
1707
|
e.pure.vector("address", u),
|
|
1699
1708
|
// Rule IDs
|
|
1700
|
-
|
|
1709
|
+
y(o.accountCap, e.object)
|
|
1701
1710
|
// Account capability
|
|
1702
1711
|
],
|
|
1703
|
-
typeArguments: [
|
|
1704
|
-
}) : v ?
|
|
1712
|
+
typeArguments: [c]
|
|
1713
|
+
}) : v ? _ = e.moveCall({
|
|
1705
1714
|
target: `${r.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1706
1715
|
arguments: [
|
|
1707
1716
|
e.object("0x06"),
|
|
@@ -1716,11 +1725,11 @@ async function vt(e, n, o) {
|
|
|
1716
1725
|
// Asset IDs
|
|
1717
1726
|
e.pure.vector("address", u),
|
|
1718
1727
|
// Rule IDs
|
|
1719
|
-
|
|
1728
|
+
y(g, e.object)
|
|
1720
1729
|
// Account capability
|
|
1721
1730
|
],
|
|
1722
|
-
typeArguments: [
|
|
1723
|
-
}) :
|
|
1731
|
+
typeArguments: [c]
|
|
1732
|
+
}) : _ = e.moveCall({
|
|
1724
1733
|
target: `${r.package}::incentive_v3::claim_reward`,
|
|
1725
1734
|
arguments: [
|
|
1726
1735
|
e.object("0x06"),
|
|
@@ -1736,36 +1745,36 @@ async function vt(e, n, o) {
|
|
|
1736
1745
|
e.pure.vector("address", u)
|
|
1737
1746
|
// Rule IDs
|
|
1738
1747
|
],
|
|
1739
|
-
typeArguments: [
|
|
1748
|
+
typeArguments: [c]
|
|
1740
1749
|
});
|
|
1741
1750
|
const [T] = e.moveCall({
|
|
1742
1751
|
target: "0x2::coin::from_balance",
|
|
1743
|
-
arguments: [
|
|
1744
|
-
typeArguments: [
|
|
1752
|
+
arguments: [_],
|
|
1753
|
+
typeArguments: [c]
|
|
1745
1754
|
});
|
|
1746
1755
|
if (o?.customCoinReceive.type === "transfer") {
|
|
1747
1756
|
if (!o.customCoinReceive.transfer)
|
|
1748
1757
|
throw new Error("customCoinReceive.transfer is required");
|
|
1749
1758
|
e.transferObjects(
|
|
1750
1759
|
[T],
|
|
1751
|
-
|
|
1760
|
+
y(o.customCoinReceive.transfer, e.pure.address)
|
|
1752
1761
|
);
|
|
1753
1762
|
}
|
|
1754
1763
|
if (o?.customCoinReceive.type === "depositNAVI") {
|
|
1755
|
-
const
|
|
1756
|
-
|
|
1764
|
+
const oe = l(f.totalSupplyAmount).shiftedBy(-9), ne = l(f.supplyCapCeiling).shiftedBy(-27);
|
|
1765
|
+
oe.plus(m).isGreaterThan(ne) && o?.customCoinReceive.depositNAVI?.fallbackReceiveAddress ? e.transferObjects(
|
|
1757
1766
|
[T],
|
|
1758
1767
|
e.pure.address(o.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
1759
|
-
) : await
|
|
1768
|
+
) : await be(e, f, T, o);
|
|
1760
1769
|
} else
|
|
1761
|
-
|
|
1770
|
+
i.push({
|
|
1762
1771
|
coin: T,
|
|
1763
|
-
identifier:
|
|
1772
|
+
identifier: f,
|
|
1764
1773
|
owner: g,
|
|
1765
1774
|
isEMode: v
|
|
1766
1775
|
});
|
|
1767
1776
|
} else if (o?.accountCap || v) {
|
|
1768
|
-
const
|
|
1777
|
+
const _ = e.moveCall({
|
|
1769
1778
|
target: `${r.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
1770
1779
|
arguments: [
|
|
1771
1780
|
e.object("0x06"),
|
|
@@ -1780,18 +1789,18 @@ async function vt(e, n, o) {
|
|
|
1780
1789
|
// Asset IDs
|
|
1781
1790
|
e.pure.vector("address", u),
|
|
1782
1791
|
// Rule IDs
|
|
1783
|
-
|
|
1792
|
+
y(o?.accountCap || g, e.object)
|
|
1784
1793
|
// Account capability
|
|
1785
1794
|
],
|
|
1786
|
-
typeArguments: [
|
|
1795
|
+
typeArguments: [c]
|
|
1787
1796
|
}), [T] = e.moveCall({
|
|
1788
1797
|
target: "0x2::coin::from_balance",
|
|
1789
|
-
arguments: [
|
|
1790
|
-
typeArguments: [
|
|
1798
|
+
arguments: [_],
|
|
1799
|
+
typeArguments: [c]
|
|
1791
1800
|
});
|
|
1792
1801
|
e.transferObjects(
|
|
1793
1802
|
[T],
|
|
1794
|
-
|
|
1803
|
+
y(o?.accountCap || g, e.pure.address)
|
|
1795
1804
|
);
|
|
1796
1805
|
} else
|
|
1797
1806
|
e.moveCall({
|
|
@@ -1810,75 +1819,75 @@ async function vt(e, n, o) {
|
|
|
1810
1819
|
e.pure.vector("address", u)
|
|
1811
1820
|
// Rule IDs
|
|
1812
1821
|
],
|
|
1813
|
-
typeArguments: [
|
|
1822
|
+
typeArguments: [c]
|
|
1814
1823
|
});
|
|
1815
1824
|
}
|
|
1816
|
-
return
|
|
1825
|
+
return i;
|
|
1817
1826
|
}
|
|
1818
1827
|
export {
|
|
1819
|
-
|
|
1828
|
+
W as Address,
|
|
1820
1829
|
w as DEFAULT_CACHE_TIME,
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1830
|
+
D as DEFAULT_MARKET_IDENTITY,
|
|
1831
|
+
He as FlashLoanAssetConfig,
|
|
1832
|
+
qe as IncentiveAPYInfo,
|
|
1833
|
+
pe as IncentivePoolInfo,
|
|
1825
1834
|
Le as IncentivePoolInfoByPhase,
|
|
1826
1835
|
E as MARKETS,
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1836
|
+
ke as Market,
|
|
1837
|
+
We as OracleInfo,
|
|
1838
|
+
N as PoolOperator,
|
|
1839
|
+
Ge as ReserveDataInfo,
|
|
1840
|
+
M as UserPositions,
|
|
1841
|
+
de as UserStateInfo,
|
|
1842
|
+
Je as borrowCoinPTB,
|
|
1834
1843
|
vt as claimLendingRewardsPTB,
|
|
1835
1844
|
_e as createAccountCapPTB,
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1845
|
+
et as createEModeCapPTB,
|
|
1846
|
+
be as depositCoinPTB,
|
|
1847
|
+
tt as emodeIdentityId,
|
|
1848
|
+
Te as enterEModePTB,
|
|
1849
|
+
xe as exitEModePTB,
|
|
1841
1850
|
Pe as filterPriceFeeds,
|
|
1842
1851
|
lt as flashloanPTB,
|
|
1843
|
-
|
|
1852
|
+
je as getAccountCapOwnerPTB,
|
|
1844
1853
|
L as getAllFlashLoanAssets,
|
|
1845
|
-
|
|
1854
|
+
Xe as getBorrowFee,
|
|
1846
1855
|
it as getCoins,
|
|
1847
1856
|
k as getConfig,
|
|
1848
|
-
|
|
1857
|
+
Ke as getFees,
|
|
1849
1858
|
ut as getFlashLoanAsset,
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1859
|
+
rt as getHealthFactor,
|
|
1860
|
+
Ie as getHealthFactorPTB,
|
|
1861
|
+
Be as getLendingPositions,
|
|
1862
|
+
nt as getLendingState,
|
|
1863
|
+
Ze as getMarket,
|
|
1855
1864
|
j as getMarketConfig,
|
|
1856
|
-
|
|
1865
|
+
Ce as getMarkets,
|
|
1857
1866
|
B as getPool,
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1867
|
+
R as getPools,
|
|
1868
|
+
te as getPriceFeeds,
|
|
1869
|
+
Ae as getPythStalePriceFeedId,
|
|
1870
|
+
at as getSimulatedHealthFactor,
|
|
1871
|
+
Z as getSimulatedHealthFactorPTB,
|
|
1872
|
+
ze as getStats,
|
|
1873
|
+
ct as getTransactions,
|
|
1865
1874
|
mt as getUserAvailableLendingRewards,
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1875
|
+
ft as getUserClaimedRewardHistory,
|
|
1876
|
+
X as getUserEModeCaps,
|
|
1877
|
+
yt as getUserTotalClaimedReward,
|
|
1869
1878
|
dt as liquidatePTB,
|
|
1870
|
-
|
|
1879
|
+
ot as mergeCoinsPTB,
|
|
1871
1880
|
b as normalizeCoinType,
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1881
|
+
he as parsePoolUID,
|
|
1882
|
+
y as parseTxValue,
|
|
1883
|
+
Qe as repayCoinPTB,
|
|
1875
1884
|
pt as repayFlashLoanPTB,
|
|
1876
1885
|
gt as summaryLendingRewards,
|
|
1877
1886
|
st as updateOraclePriceBeforeUserOperationPTB,
|
|
1878
|
-
|
|
1879
|
-
|
|
1887
|
+
Se as updateOraclePricesPTB,
|
|
1888
|
+
$e as updatePythPriceFeeds,
|
|
1880
1889
|
A as withCache,
|
|
1881
1890
|
I as withSingleton,
|
|
1882
|
-
|
|
1891
|
+
Ye as withdrawCoinPTB
|
|
1883
1892
|
};
|
|
1884
1893
|
//# sourceMappingURL=index.esm.js.map
|