@naviprotocol/lending 1.3.0-dev.2 → 1.3.0-dev.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 +289 -264
- package/dist/index.esm.js.map +1 -1
- package/dist/pool.d.ts +17 -4
- package/dist/pool.d.ts.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3,14 +3,14 @@ import { bcs as s, toHex as H, fromHex as q } from "@mysten/bcs";
|
|
|
3
3
|
import { SuiClient as z, getFullnodeUrl as O } from "@mysten/sui/client";
|
|
4
4
|
import W from "lodash.camelcase";
|
|
5
5
|
import { normalizeStructTag as K } from "@mysten/sui/utils";
|
|
6
|
-
import { SuiPriceServiceConnection as
|
|
6
|
+
import { SuiPriceServiceConnection as N, SuiPythClient as Y } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import T from "bignumber.js";
|
|
8
|
-
import { bcs as
|
|
9
|
-
const
|
|
8
|
+
import { bcs as h } from "@mysten/sui/bcs";
|
|
9
|
+
const V = s.bytes(32).transform({
|
|
10
10
|
// To change the input type, you need to provide a type definition for the input
|
|
11
11
|
input: (e) => q(e),
|
|
12
12
|
output: (e) => H(e)
|
|
13
|
-
}),
|
|
13
|
+
}), fe = s.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
15
|
asset_id: s.u8(),
|
|
16
16
|
/** Annual Percentage Yield as a 256-bit integer */
|
|
@@ -19,9 +19,9 @@ const R = s.bytes(32).transform({
|
|
|
19
19
|
coin_types: s.vector(s.string())
|
|
20
20
|
}), J = s.struct("IncentivePoolInfo", {
|
|
21
21
|
/** Unique pool identifier */
|
|
22
|
-
pool_id:
|
|
22
|
+
pool_id: V,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: V,
|
|
25
25
|
/** Current phase of the incentive program */
|
|
26
26
|
phase: s.u64(),
|
|
27
27
|
/** Timestamp when the incentive started */
|
|
@@ -44,12 +44,12 @@ const R = s.bytes(32).transform({
|
|
|
44
44
|
available: s.u256(),
|
|
45
45
|
/** Total amount of incentives */
|
|
46
46
|
total: s.u256()
|
|
47
|
-
}),
|
|
47
|
+
}), me = s.struct("IncentivePoolInfoByPhase", {
|
|
48
48
|
/** Phase number */
|
|
49
49
|
phase: s.u64(),
|
|
50
50
|
/** List of incentive pools in this phase */
|
|
51
51
|
pools: s.vector(J)
|
|
52
|
-
}),
|
|
52
|
+
}), pe = s.struct("OracleInfo", {
|
|
53
53
|
/** Oracle identifier */
|
|
54
54
|
oracle_id: s.u8(),
|
|
55
55
|
/** Current price as a 256-bit integer */
|
|
@@ -132,94 +132,94 @@ const R = s.bytes(32).transform({
|
|
|
132
132
|
}), I = new z({
|
|
133
133
|
url: O("mainnet")
|
|
134
134
|
});
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
return e.forEach((
|
|
135
|
+
function E(e) {
|
|
136
|
+
const r = [];
|
|
137
|
+
return e.forEach((a, t) => {
|
|
138
138
|
const c = t === e.length - 1;
|
|
139
|
-
if (typeof
|
|
140
|
-
const { client: n, disableCache: o, cacheTime: i, ...u } =
|
|
141
|
-
|
|
139
|
+
if (typeof a == "object" && c) {
|
|
140
|
+
const { client: n, disableCache: o, cacheTime: i, ...u } = a;
|
|
141
|
+
r.push(u);
|
|
142
142
|
} else
|
|
143
|
-
|
|
144
|
-
}), JSON.stringify(
|
|
143
|
+
r.push(a);
|
|
144
|
+
}), JSON.stringify(r);
|
|
145
145
|
}
|
|
146
146
|
function _(e) {
|
|
147
|
-
const
|
|
148
|
-
return (...
|
|
149
|
-
const t =
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
})),
|
|
147
|
+
const r = {};
|
|
148
|
+
return (...a) => {
|
|
149
|
+
const t = E(a);
|
|
150
|
+
return r[t] || (r[t] = e(...a).finally(() => {
|
|
151
|
+
r[t] = null;
|
|
152
|
+
})), r[t];
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
function A(e) {
|
|
156
|
-
let
|
|
157
|
-
return (...
|
|
158
|
-
const t =
|
|
159
|
-
return !(t != null && t.disableCache) && typeof (n == null ? void 0 : n.data) != "undefined" && (typeof (t == null ? void 0 : t.cacheTime) == "undefined" || t.cacheTime > Date.now() - n.cacheAt) ? n.data : e(...
|
|
156
|
+
let r = {};
|
|
157
|
+
return (...a) => {
|
|
158
|
+
const t = a[a.length - 1], c = E(a), n = r[c];
|
|
159
|
+
return !(t != null && t.disableCache) && typeof (n == null ? void 0 : n.data) != "undefined" && (typeof (t == null ? void 0 : t.cacheTime) == "undefined" || t.cacheTime > Date.now() - n.cacheAt) ? n.data : e(...a).then((o) => (r[c] = {
|
|
160
160
|
data: o,
|
|
161
161
|
cacheAt: Date.now()
|
|
162
162
|
}, o));
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
return Array.isArray(e) ? e.map((
|
|
167
|
-
(
|
|
168
|
-
...
|
|
169
|
-
[W(
|
|
165
|
+
function k(e) {
|
|
166
|
+
return Array.isArray(e) ? e.map((r) => k(r)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
167
|
+
(r, a) => ({
|
|
168
|
+
...r,
|
|
169
|
+
[W(a)]: k(e[a])
|
|
170
170
|
}),
|
|
171
171
|
{}
|
|
172
172
|
) : e;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
return typeof e == "object" ? e :
|
|
174
|
+
function m(e, r) {
|
|
175
|
+
return typeof e == "object" ? e : r(e);
|
|
176
176
|
}
|
|
177
|
-
function X(e,
|
|
178
|
-
return typeof
|
|
177
|
+
function X(e, r) {
|
|
178
|
+
return typeof r == "string" ? e.object(r) : typeof r == "object" && r.$kind ? r : e.object(r.contract.pool);
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function $(e, r, a) {
|
|
181
181
|
if (e.results && e.results.length > 0) {
|
|
182
182
|
if (e.results[0].returnValues && e.results[0].returnValues.length > 0)
|
|
183
|
-
return e.results[0].returnValues.map((t, c) => (
|
|
183
|
+
return e.results[0].returnValues.map((t, c) => (r[c] || r[0]).parse(Uint8Array.from(t[0])));
|
|
184
184
|
} else if (e.error)
|
|
185
185
|
return console.log(`Get an error, msg: ${e.error}`), [];
|
|
186
186
|
return [];
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function p(e) {
|
|
189
189
|
return K(e);
|
|
190
190
|
}
|
|
191
191
|
function L(e) {
|
|
192
|
-
const
|
|
193
|
-
return
|
|
192
|
+
const r = (e || 0) / Math.pow(10, 27);
|
|
193
|
+
return r > Math.pow(10, 5) ? 1 / 0 : r;
|
|
194
194
|
}
|
|
195
|
-
new
|
|
195
|
+
new N("https://hermes.pyth.network", {
|
|
196
196
|
timeout: 2e4
|
|
197
197
|
});
|
|
198
|
-
const Z = 27,
|
|
199
|
-
if (!Number(e) || !Number(
|
|
200
|
-
const
|
|
201
|
-
return new T(e).multipliedBy(new T(
|
|
198
|
+
const Z = 27, R = (e, r) => {
|
|
199
|
+
if (!Number(e) || !Number(r)) return new T(0);
|
|
200
|
+
const a = new T(1).shiftedBy(1 * Z), t = a.multipliedBy(new T(0.5));
|
|
201
|
+
return new T(e).multipliedBy(new T(r)).plus(t).dividedBy(a).integerValue(T.ROUND_DOWN);
|
|
202
202
|
}, w = A(
|
|
203
203
|
_(async (e) => {
|
|
204
|
-
const
|
|
205
|
-
return (await fetch(
|
|
204
|
+
const r = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}&v=2`;
|
|
205
|
+
return (await fetch(r).then((t) => t.json())).data;
|
|
206
206
|
})
|
|
207
207
|
), g = 1e3 * 60 * 5;
|
|
208
208
|
var P = /* @__PURE__ */ ((e) => (e[e.Supply = 1] = "Supply", e[e.Withdraw = 2] = "Withdraw", e[e.Borrow = 3] = "Borrow", e[e.Repay = 4] = "Repay", e))(P || {});
|
|
209
209
|
const S = A(
|
|
210
210
|
_(async (e) => {
|
|
211
|
-
const
|
|
212
|
-
return (await fetch(
|
|
211
|
+
const r = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
212
|
+
return (await fetch(r).then((t) => t.json())).data;
|
|
213
213
|
})
|
|
214
214
|
);
|
|
215
|
-
async function
|
|
216
|
-
const
|
|
217
|
-
...
|
|
215
|
+
async function v(e, r) {
|
|
216
|
+
const a = await S({
|
|
217
|
+
...r,
|
|
218
218
|
cacheTime: g
|
|
219
219
|
});
|
|
220
220
|
if (typeof e == "object")
|
|
221
221
|
return e;
|
|
222
|
-
const t =
|
|
222
|
+
const t = a.find((c) => typeof e == "string" ? p(c.suiCoinType) === p(e) : typeof e == "number" ? c.id === e : !1);
|
|
223
223
|
if (!t)
|
|
224
224
|
throw new Error("Pool not found");
|
|
225
225
|
return t;
|
|
@@ -231,20 +231,20 @@ const we = A(
|
|
|
231
231
|
async (e) => await fetch("https://open-api.naviprotocol.io/api/navi/fee").then((t) => t.json())
|
|
232
232
|
)
|
|
233
233
|
);
|
|
234
|
-
async function x(e,
|
|
234
|
+
async function x(e, r, a, t) {
|
|
235
235
|
const c = await w({
|
|
236
236
|
...t,
|
|
237
237
|
cacheTime: g
|
|
238
|
-
}), n = await
|
|
239
|
-
if (
|
|
238
|
+
}), n = await v(r, t), o = typeof a == "object" && a.$kind === "GasCoin";
|
|
239
|
+
if (p(n.suiCoinType) === p("0x2::sui::SUI") && o) {
|
|
240
240
|
if (!(t != null && t.amount))
|
|
241
241
|
throw new Error("Amount is required for sui coin");
|
|
242
|
-
|
|
242
|
+
a = e.splitCoins(a, [t.amount]);
|
|
243
243
|
}
|
|
244
244
|
let i;
|
|
245
|
-
return typeof (t == null ? void 0 : t.amount) != "undefined" ? i =
|
|
245
|
+
return typeof (t == null ? void 0 : t.amount) != "undefined" ? i = m(t.amount, e.pure.u64) : i = e.moveCall({
|
|
246
246
|
target: "0x2::coin::value",
|
|
247
|
-
arguments: [
|
|
247
|
+
arguments: [m(a, e.object)],
|
|
248
248
|
typeArguments: [n.suiCoinType]
|
|
249
249
|
}), t != null && t.accountCap ? e.moveCall({
|
|
250
250
|
target: `${c.package}::incentive_v3::deposit_with_account_cap`,
|
|
@@ -253,10 +253,10 @@ async function x(e, a, r, t) {
|
|
|
253
253
|
e.object(c.storage),
|
|
254
254
|
e.object(n.contract.pool),
|
|
255
255
|
e.pure.u8(n.id),
|
|
256
|
-
|
|
256
|
+
m(a, e.object),
|
|
257
257
|
e.object(c.incentiveV2),
|
|
258
258
|
e.object(c.incentiveV3),
|
|
259
|
-
|
|
259
|
+
m(t.accountCap, e.object)
|
|
260
260
|
],
|
|
261
261
|
typeArguments: [n.suiCoinType]
|
|
262
262
|
}) : e.moveCall({
|
|
@@ -266,7 +266,7 @@ async function x(e, a, r, t) {
|
|
|
266
266
|
e.object(c.storage),
|
|
267
267
|
e.object(n.contract.pool),
|
|
268
268
|
e.pure.u8(n.id),
|
|
269
|
-
|
|
269
|
+
m(a, e.object),
|
|
270
270
|
i,
|
|
271
271
|
e.object(c.incentiveV2),
|
|
272
272
|
e.object(c.incentiveV3)
|
|
@@ -274,14 +274,14 @@ async function x(e, a, r, t) {
|
|
|
274
274
|
typeArguments: [n.suiCoinType]
|
|
275
275
|
}), n.id === 0 && e.moveCall({
|
|
276
276
|
target: `${c.package}::pool::refresh_stake`,
|
|
277
|
-
arguments: [e.object(n.contract.pool), e.object("
|
|
277
|
+
arguments: [e.object(n.contract.pool), e.object("0x06")]
|
|
278
278
|
}), e;
|
|
279
279
|
}
|
|
280
|
-
async function be(e,
|
|
280
|
+
async function be(e, r, a, t) {
|
|
281
281
|
const c = await w({
|
|
282
282
|
...t,
|
|
283
283
|
cacheTime: g
|
|
284
|
-
}), n = await
|
|
284
|
+
}), n = await v(r, t), o = m(a, e.pure.u64);
|
|
285
285
|
let i;
|
|
286
286
|
if (t != null && t.accountCap) {
|
|
287
287
|
const [l] = e.moveCall({
|
|
@@ -295,7 +295,7 @@ async function be(e, a, r, t) {
|
|
|
295
295
|
o,
|
|
296
296
|
e.object(c.incentiveV2),
|
|
297
297
|
e.object(c.incentiveV3),
|
|
298
|
-
|
|
298
|
+
m(t.accountCap, e.object),
|
|
299
299
|
e.object("0x05")
|
|
300
300
|
],
|
|
301
301
|
typeArguments: [n.suiCoinType]
|
|
@@ -325,11 +325,11 @@ async function be(e, a, r, t) {
|
|
|
325
325
|
typeArguments: [n.suiCoinType]
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
|
-
async function ve(e,
|
|
328
|
+
async function ve(e, r, a, t) {
|
|
329
329
|
const c = await w({
|
|
330
330
|
...t,
|
|
331
331
|
cacheTime: g
|
|
332
|
-
}), n = await
|
|
332
|
+
}), n = await v(r, t), o = m(a, e.pure.u64);
|
|
333
333
|
let i;
|
|
334
334
|
if (t != null && t.accountCap) {
|
|
335
335
|
const [l] = e.moveCall({
|
|
@@ -343,7 +343,7 @@ async function ve(e, a, r, t) {
|
|
|
343
343
|
o,
|
|
344
344
|
e.object(c.incentiveV2),
|
|
345
345
|
e.object(c.incentiveV3),
|
|
346
|
-
|
|
346
|
+
m(t.accountCap, e.object),
|
|
347
347
|
e.object("0x05")
|
|
348
348
|
],
|
|
349
349
|
typeArguments: [n.suiCoinType]
|
|
@@ -373,20 +373,20 @@ async function ve(e, a, r, t) {
|
|
|
373
373
|
typeArguments: [n.suiCoinType]
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
|
-
async function Ce(e,
|
|
376
|
+
async function Ce(e, r, a, t) {
|
|
377
377
|
const c = await w({
|
|
378
378
|
...t,
|
|
379
379
|
cacheTime: g
|
|
380
|
-
}), n = await
|
|
381
|
-
if (
|
|
380
|
+
}), n = await v(r, t), o = typeof a == "object" && a.$kind === "GasCoin";
|
|
381
|
+
if (p(n.suiCoinType) === p("0x2::sui::SUI") && o) {
|
|
382
382
|
if (!(t != null && t.amount))
|
|
383
383
|
throw new Error("Amount is required for sui coin");
|
|
384
|
-
|
|
384
|
+
a = e.splitCoins(a, [t.amount]);
|
|
385
385
|
}
|
|
386
386
|
let i;
|
|
387
|
-
return typeof (t == null ? void 0 : t.amount) != "undefined" ? i =
|
|
387
|
+
return typeof (t == null ? void 0 : t.amount) != "undefined" ? i = m(t.amount, e.pure.u64) : i = e.moveCall({
|
|
388
388
|
target: "0x2::coin::value",
|
|
389
|
-
arguments: [
|
|
389
|
+
arguments: [m(a, e.object)],
|
|
390
390
|
typeArguments: [n.suiCoinType]
|
|
391
391
|
}), t != null && t.accountCap ? e.moveCall({
|
|
392
392
|
target: `${c.package}::incentive_v3::repay_with_account_cap`,
|
|
@@ -396,11 +396,11 @@ async function Ce(e, a, r, t) {
|
|
|
396
396
|
e.object(c.storage),
|
|
397
397
|
e.object(n.contract.pool),
|
|
398
398
|
e.pure.u8(n.id),
|
|
399
|
-
|
|
399
|
+
m(a, e.object),
|
|
400
400
|
i,
|
|
401
401
|
e.object(c.incentiveV2),
|
|
402
402
|
e.object(c.incentiveV3),
|
|
403
|
-
|
|
403
|
+
m(t.accountCap, e.object)
|
|
404
404
|
],
|
|
405
405
|
typeArguments: [n.suiCoinType]
|
|
406
406
|
}) : e.moveCall({
|
|
@@ -411,7 +411,7 @@ async function Ce(e, a, r, t) {
|
|
|
411
411
|
e.object(c.storage),
|
|
412
412
|
e.object(n.contract.pool),
|
|
413
413
|
e.pure.u8(n.id),
|
|
414
|
-
|
|
414
|
+
m(a, e.object),
|
|
415
415
|
i,
|
|
416
416
|
e.object(c.incentiveV2),
|
|
417
417
|
e.object(c.incentiveV3)
|
|
@@ -420,22 +420,47 @@ async function Ce(e, a, r, t) {
|
|
|
420
420
|
}), e;
|
|
421
421
|
}
|
|
422
422
|
const _e = A(
|
|
423
|
-
_(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
423
|
+
_(
|
|
424
|
+
async (e) => {
|
|
425
|
+
var c;
|
|
426
|
+
const r = await w({
|
|
427
|
+
...e
|
|
428
|
+
});
|
|
429
|
+
if (e != null && e.address && (e != null && e.asset))
|
|
430
|
+
try {
|
|
431
|
+
const n = await v(e.asset, e), o = (c = e == null ? void 0 : e.client) != null ? c : I, i = new B();
|
|
432
|
+
i.moveCall({
|
|
433
|
+
target: `${r.package}::incentive_v3::get_borrow_fee_v2`,
|
|
434
|
+
arguments: [
|
|
435
|
+
i.object(r.incentiveV3),
|
|
436
|
+
i.pure.address(e.address),
|
|
437
|
+
i.pure.u8(n.id),
|
|
438
|
+
i.pure.u64(1e4)
|
|
439
|
+
],
|
|
440
|
+
typeArguments: [n.suiCoinType]
|
|
441
|
+
});
|
|
442
|
+
const u = await o.devInspectTransactionBlock({
|
|
443
|
+
transactionBlock: i,
|
|
444
|
+
sender: e.address
|
|
445
|
+
}), l = $(u, [h.u64()]);
|
|
446
|
+
return (Number(l[0]) || 0) / 1e4;
|
|
447
|
+
} catch (n) {
|
|
448
|
+
console.error(n);
|
|
449
|
+
}
|
|
450
|
+
const t = (await I.getObject({
|
|
451
|
+
id: r.incentiveV3,
|
|
452
|
+
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
453
|
+
})).data.content.fields.borrow_fee_rate;
|
|
454
|
+
return Number(t) / 100;
|
|
455
|
+
}
|
|
456
|
+
)
|
|
432
457
|
);
|
|
433
|
-
function je(e,
|
|
434
|
-
const t = typeof (
|
|
458
|
+
function je(e, r, a) {
|
|
459
|
+
const t = typeof (a == null ? void 0 : a.balance) == "number", c = t ? a.balance : 0;
|
|
435
460
|
let n = 0;
|
|
436
461
|
const o = [];
|
|
437
462
|
let i = "";
|
|
438
|
-
if (
|
|
463
|
+
if (r.sort((l, d) => Number(d.balance) - Number(l.balance)).forEach((l) => {
|
|
439
464
|
if (!(t && n >= c) && Number(l.balance) !== 0) {
|
|
440
465
|
if (i || (i = l.coinType), i !== l.coinType)
|
|
441
466
|
throw new Error("All coins must be of the same type");
|
|
@@ -447,16 +472,16 @@ function je(e, a, r) {
|
|
|
447
472
|
throw new Error(
|
|
448
473
|
`Balance is less than the specified balance: ${n} < ${c}`
|
|
449
474
|
);
|
|
450
|
-
if (
|
|
475
|
+
if (p(i) === p("0x2::sui::SUI") && (a != null && a.useGasCoin))
|
|
451
476
|
return t ? e.splitCoins(e.gas, [e.pure.u64(c)]) : e.gas;
|
|
452
477
|
const u = o.length === 1 ? e.object(o[0]) : e.mergeCoins(o[0], o.slice(1));
|
|
453
478
|
return t ? e.splitCoins(u, [e.pure.u64(c)]) : u;
|
|
454
479
|
}
|
|
455
|
-
async function D(e,
|
|
480
|
+
async function D(e, r, a, t, c, n, o) {
|
|
456
481
|
const i = await w({
|
|
457
482
|
...o,
|
|
458
483
|
cacheTime: g
|
|
459
|
-
}), u = await
|
|
484
|
+
}), u = await v(a, o);
|
|
460
485
|
return e.moveCall({
|
|
461
486
|
target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
462
487
|
arguments: [
|
|
@@ -464,68 +489,68 @@ async function D(e, a, r, t, c, n, o) {
|
|
|
464
489
|
e.object(i.storage),
|
|
465
490
|
e.object(i.oracle.priceOracle),
|
|
466
491
|
X(e, u),
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
492
|
+
m(r, e.pure.address),
|
|
493
|
+
m(u.id, e.pure.u8),
|
|
494
|
+
m(t, e.pure.u64),
|
|
495
|
+
m(c, e.pure.u64),
|
|
496
|
+
m(n, e.pure.bool)
|
|
472
497
|
],
|
|
473
498
|
typeArguments: [u.suiCoinType]
|
|
474
499
|
});
|
|
475
500
|
}
|
|
476
|
-
async function ee(e,
|
|
477
|
-
return D(e,
|
|
501
|
+
async function ee(e, r, a) {
|
|
502
|
+
return D(e, r, 0, 0, 0, !1, a);
|
|
478
503
|
}
|
|
479
504
|
const Te = A(
|
|
480
|
-
async (e,
|
|
505
|
+
async (e, r) => {
|
|
481
506
|
var l;
|
|
482
|
-
const
|
|
483
|
-
...
|
|
507
|
+
const a = await w({
|
|
508
|
+
...r,
|
|
484
509
|
cacheTime: g
|
|
485
|
-
}), t = new B(), c = (l =
|
|
510
|
+
}), t = new B(), c = (l = r == null ? void 0 : r.client) != null ? l : I, n = await S(r);
|
|
486
511
|
t.moveCall({
|
|
487
|
-
target: `${
|
|
488
|
-
arguments: [t.object(
|
|
512
|
+
target: `${a.uiGetter}::getter_unchecked::get_user_state`,
|
|
513
|
+
arguments: [t.object(a.storage), t.pure.address(e)]
|
|
489
514
|
});
|
|
490
515
|
const o = await c.devInspectTransactionBlock({
|
|
491
516
|
transactionBlock: t,
|
|
492
517
|
sender: e
|
|
493
|
-
}), i =
|
|
494
|
-
return
|
|
518
|
+
}), i = $(o, [h.vector(Q)]);
|
|
519
|
+
return k(
|
|
495
520
|
i[0].filter((d) => d.supply_balance !== "0" || d.borrow_balance !== "0")
|
|
496
521
|
).map((d) => {
|
|
497
|
-
const
|
|
522
|
+
const b = n.find((C) => C.id === d.assetId), f = R(
|
|
498
523
|
d.supplyBalance,
|
|
499
|
-
|
|
500
|
-
).toString(), y =
|
|
524
|
+
b.currentSupplyIndex
|
|
525
|
+
).toString(), y = R(
|
|
501
526
|
d.borrowBalance,
|
|
502
|
-
|
|
527
|
+
b.currentBorrowIndex
|
|
503
528
|
).toString();
|
|
504
529
|
return {
|
|
505
530
|
...d,
|
|
506
|
-
supplyBalance:
|
|
531
|
+
supplyBalance: f,
|
|
507
532
|
borrowBalance: y,
|
|
508
|
-
pool:
|
|
533
|
+
pool: b
|
|
509
534
|
};
|
|
510
535
|
}).filter((d) => !!d.pool);
|
|
511
536
|
}
|
|
512
537
|
);
|
|
513
|
-
async function Ie(e,
|
|
538
|
+
async function Ie(e, r) {
|
|
514
539
|
var o;
|
|
515
|
-
const
|
|
516
|
-
await ee(t, e,
|
|
517
|
-
const c = await
|
|
540
|
+
const a = (o = r == null ? void 0 : r.client) != null ? o : I, t = new B();
|
|
541
|
+
await ee(t, e, r);
|
|
542
|
+
const c = await a.devInspectTransactionBlock({
|
|
518
543
|
transactionBlock: t,
|
|
519
544
|
sender: e
|
|
520
|
-
}), n =
|
|
545
|
+
}), n = $(c, [h.u256()]);
|
|
521
546
|
return L(Number(n[0]) || 0);
|
|
522
547
|
}
|
|
523
|
-
async function Ae(e,
|
|
524
|
-
var
|
|
525
|
-
const c = (
|
|
548
|
+
async function Ae(e, r, a, t) {
|
|
549
|
+
var f;
|
|
550
|
+
const c = (f = t == null ? void 0 : t.client) != null ? f : I, n = new B();
|
|
526
551
|
let o = 0, i = 0;
|
|
527
|
-
const u = await
|
|
528
|
-
if (
|
|
552
|
+
const u = await v(r, t);
|
|
553
|
+
if (a.forEach((y) => {
|
|
529
554
|
y.type === P.Supply ? o += y.amount : y.type === P.Withdraw ? o -= y.amount : y.type === P.Borrow ? i += y.amount : y.type === P.Repay && (i -= y.amount);
|
|
530
555
|
}), o * i < 0)
|
|
531
556
|
throw new Error("Invalid operations");
|
|
@@ -542,47 +567,47 @@ async function Ae(e, a, r, t) {
|
|
|
542
567
|
const d = await c.devInspectTransactionBlock({
|
|
543
568
|
transactionBlock: n,
|
|
544
569
|
sender: e
|
|
545
|
-
}),
|
|
546
|
-
return L(Number(
|
|
570
|
+
}), b = $(d, [h.u256()]);
|
|
571
|
+
return L(Number(b[0]) || 0);
|
|
547
572
|
}
|
|
548
573
|
const Pe = _(
|
|
549
|
-
async (e,
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${
|
|
574
|
+
async (e, r) => {
|
|
575
|
+
const a = new URLSearchParams();
|
|
576
|
+
r != null && r.cursor && a.set("cursor", r.cursor), a.set("userAddress", e);
|
|
577
|
+
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${a.toString()}`;
|
|
553
578
|
return (await fetch(t).then((n) => n.json())).data;
|
|
554
579
|
}
|
|
555
580
|
);
|
|
556
|
-
async function
|
|
581
|
+
async function Be(e, r) {
|
|
557
582
|
var n;
|
|
558
|
-
let
|
|
559
|
-
const t = [], c = (n =
|
|
583
|
+
let a = null;
|
|
584
|
+
const t = [], c = (n = r == null ? void 0 : r.client) != null ? n : I;
|
|
560
585
|
do {
|
|
561
586
|
let o;
|
|
562
|
-
if (
|
|
587
|
+
if (r != null && r.coinType ? o = await c.getCoins({
|
|
563
588
|
owner: e,
|
|
564
|
-
coinType:
|
|
565
|
-
cursor:
|
|
589
|
+
coinType: r == null ? void 0 : r.coinType,
|
|
590
|
+
cursor: a,
|
|
566
591
|
limit: 100
|
|
567
592
|
}) : o = await c.getAllCoins({
|
|
568
593
|
owner: e,
|
|
569
|
-
cursor:
|
|
594
|
+
cursor: a,
|
|
570
595
|
limit: 100
|
|
571
596
|
}), !o.data || !o.data.length)
|
|
572
597
|
break;
|
|
573
|
-
t.push(...o.data),
|
|
574
|
-
} while (
|
|
598
|
+
t.push(...o.data), a = o.nextCursor;
|
|
599
|
+
} while (a);
|
|
575
600
|
return t;
|
|
576
601
|
}
|
|
577
|
-
const M = new
|
|
602
|
+
const M = new N("https://hermes.pyth.network", {
|
|
578
603
|
timeout: 1e4
|
|
579
604
|
});
|
|
580
605
|
async function te(e) {
|
|
581
606
|
try {
|
|
582
|
-
const
|
|
583
|
-
if (!
|
|
607
|
+
const r = [], a = await M.getLatestPriceFeeds(e);
|
|
608
|
+
if (!a) return r;
|
|
584
609
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
585
|
-
for (const c of
|
|
610
|
+
for (const c of a) {
|
|
586
611
|
const n = c.getPriceUnchecked();
|
|
587
612
|
if (n.publishTime > t) {
|
|
588
613
|
console.warn(
|
|
@@ -592,44 +617,44 @@ async function te(e) {
|
|
|
592
617
|
}
|
|
593
618
|
t - c.getPriceUnchecked().publishTime > 30 && (console.info(
|
|
594
619
|
`stale price feed, id: ${c.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
|
|
595
|
-
),
|
|
620
|
+
), r.push(c.id));
|
|
596
621
|
}
|
|
597
|
-
return
|
|
598
|
-
} catch (
|
|
599
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${
|
|
622
|
+
return r;
|
|
623
|
+
} catch (r) {
|
|
624
|
+
throw new Error(`failed to get pyth stale price feed id, msg: ${r.message}`);
|
|
600
625
|
}
|
|
601
626
|
}
|
|
602
|
-
async function
|
|
627
|
+
async function re(e, r, a) {
|
|
603
628
|
var n;
|
|
604
|
-
const t = (n =
|
|
605
|
-
...
|
|
629
|
+
const t = (n = a == null ? void 0 : a.client) != null ? n : I, c = await w({
|
|
630
|
+
...a,
|
|
606
631
|
cacheTime: g
|
|
607
632
|
});
|
|
608
633
|
try {
|
|
609
|
-
const o = await M.getPriceFeedsUpdateData(
|
|
634
|
+
const o = await M.getPriceFeedsUpdateData(r);
|
|
610
635
|
return await new Y(
|
|
611
636
|
t,
|
|
612
637
|
c.oracle.pythStateId,
|
|
613
638
|
c.oracle.wormholeStateId
|
|
614
|
-
).updatePriceFeeds(e, o,
|
|
639
|
+
).updatePriceFeeds(e, o, r);
|
|
615
640
|
} catch (o) {
|
|
616
641
|
throw new Error(`failed to update pyth price feeds, msg: ${o.message}`);
|
|
617
642
|
}
|
|
618
643
|
}
|
|
619
|
-
async function
|
|
644
|
+
async function $e(e, r, a) {
|
|
620
645
|
const t = await w({
|
|
621
|
-
...
|
|
646
|
+
...a,
|
|
622
647
|
cacheTime: g
|
|
623
648
|
});
|
|
624
|
-
if (
|
|
625
|
-
const c =
|
|
649
|
+
if (a != null && a.updatePythPriceFeeds) {
|
|
650
|
+
const c = r.filter((n) => !!n.pythPriceFeedId).map((n) => n.pythPriceFeedId);
|
|
626
651
|
try {
|
|
627
652
|
const n = await te(c);
|
|
628
|
-
n.length > 0 && await
|
|
653
|
+
n.length > 0 && await re(e, n, a);
|
|
629
654
|
} catch {
|
|
630
655
|
}
|
|
631
656
|
}
|
|
632
|
-
for (const c of
|
|
657
|
+
for (const c of r)
|
|
633
658
|
e.moveCall({
|
|
634
659
|
target: `${t.oracle.packageId}::oracle_pro::update_single_price`,
|
|
635
660
|
arguments: [
|
|
@@ -649,37 +674,37 @@ async function Be(e, a, r) {
|
|
|
649
674
|
});
|
|
650
675
|
return e;
|
|
651
676
|
}
|
|
652
|
-
async function
|
|
677
|
+
async function ae(e) {
|
|
653
678
|
return (await w({
|
|
654
679
|
...e,
|
|
655
680
|
cacheTime: g
|
|
656
681
|
})).oracle.feeds;
|
|
657
682
|
}
|
|
658
|
-
function ke(e,
|
|
659
|
-
return e.filter((
|
|
683
|
+
function ke(e, r) {
|
|
684
|
+
return e.filter((a) => !!(r != null && r.lendingState && r.lendingState.find((c) => c.assetId === a.assetId) || r != null && r.pools && r.pools.find((c) => c.id === a.assetId)));
|
|
660
685
|
}
|
|
661
686
|
const F = A(
|
|
662
687
|
_(async (e) => {
|
|
663
|
-
const
|
|
664
|
-
return Object.keys(
|
|
665
|
-
...
|
|
688
|
+
const r = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`, a = await fetch(r).then((t) => t.json());
|
|
689
|
+
return Object.keys(a.data).map((t) => ({
|
|
690
|
+
...a.data[t],
|
|
666
691
|
coinType: t
|
|
667
692
|
}));
|
|
668
693
|
})
|
|
669
694
|
);
|
|
670
|
-
async function Se(e,
|
|
671
|
-
return (await F(
|
|
695
|
+
async function Se(e, r) {
|
|
696
|
+
return (await F(r)).find((t) => typeof e == "string" ? p(t.coinType) === p(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
|
|
672
697
|
}
|
|
673
|
-
async function Fe(e,
|
|
698
|
+
async function Fe(e, r, a, t) {
|
|
674
699
|
const c = await w({
|
|
675
700
|
...t,
|
|
676
701
|
cacheTime: g
|
|
677
|
-
}), n = await
|
|
702
|
+
}), n = await v(r, t);
|
|
678
703
|
if (!(await F({
|
|
679
704
|
...t,
|
|
680
705
|
cacheTime: g
|
|
681
706
|
})).some(
|
|
682
|
-
(d) =>
|
|
707
|
+
(d) => p(d.coinType) === p(n.suiCoinType)
|
|
683
708
|
))
|
|
684
709
|
throw new Error("Pool does not support flashloan");
|
|
685
710
|
const [u, l] = e.moveCall({
|
|
@@ -687,23 +712,23 @@ async function Fe(e, a, r, t) {
|
|
|
687
712
|
arguments: [
|
|
688
713
|
e.object(c.flashloanConfig),
|
|
689
714
|
e.object(n.contract.pool),
|
|
690
|
-
|
|
715
|
+
m(a, e.pure.u64),
|
|
691
716
|
e.object("0x05")
|
|
692
717
|
],
|
|
693
718
|
typeArguments: [n.suiCoinType]
|
|
694
719
|
});
|
|
695
720
|
return [u, l];
|
|
696
721
|
}
|
|
697
|
-
async function
|
|
722
|
+
async function Ve(e, r, a, t, c) {
|
|
698
723
|
const n = await w({
|
|
699
724
|
...c,
|
|
700
725
|
cacheTime: g
|
|
701
|
-
}), o = await
|
|
726
|
+
}), o = await v(r, c);
|
|
702
727
|
if (!(await F({
|
|
703
728
|
...c,
|
|
704
729
|
cacheTime: g
|
|
705
730
|
})).some(
|
|
706
|
-
(d) =>
|
|
731
|
+
(d) => p(d.coinType) === p(o.suiCoinType)
|
|
707
732
|
))
|
|
708
733
|
throw new Error("Pool does not support flashloan");
|
|
709
734
|
const [l] = e.moveCall({
|
|
@@ -712,18 +737,18 @@ async function Re(e, a, r, t, c) {
|
|
|
712
737
|
e.object("0x06"),
|
|
713
738
|
e.object(n.storage),
|
|
714
739
|
e.object(o.contract.pool),
|
|
715
|
-
|
|
716
|
-
|
|
740
|
+
m(a, e.object),
|
|
741
|
+
m(t, e.object)
|
|
717
742
|
],
|
|
718
743
|
typeArguments: [o.suiCoinType]
|
|
719
744
|
});
|
|
720
745
|
return [l];
|
|
721
746
|
}
|
|
722
|
-
async function
|
|
747
|
+
async function Re(e, r, a, t, c, n) {
|
|
723
748
|
const o = {
|
|
724
749
|
...n,
|
|
725
750
|
cacheTime: g
|
|
726
|
-
}, i = await w(o), u = await
|
|
751
|
+
}, i = await w(o), u = await v(r, o), l = await v(t, o), [d, b] = e.moveCall({
|
|
727
752
|
target: `${i.package}::incentive_v3::liquidation_v2`,
|
|
728
753
|
arguments: [
|
|
729
754
|
e.object("0x06"),
|
|
@@ -736,13 +761,13 @@ async function Ve(e, a, r, t, c, n) {
|
|
|
736
761
|
// Pay asset ID
|
|
737
762
|
e.object(u.contract.pool),
|
|
738
763
|
// Pay asset pool contract
|
|
739
|
-
|
|
764
|
+
m(a, e.object),
|
|
740
765
|
// Debt repayment amount
|
|
741
766
|
e.pure.u8(l.id),
|
|
742
767
|
// Collateral asset ID
|
|
743
768
|
e.object(l.contract.pool),
|
|
744
769
|
// Collateral asset pool contract
|
|
745
|
-
|
|
770
|
+
m(c, e.pure.address),
|
|
746
771
|
// Borrower address
|
|
747
772
|
e.object(i.incentiveV2),
|
|
748
773
|
// Incentive V2 contract
|
|
@@ -753,15 +778,15 @@ async function Ve(e, a, r, t, c, n) {
|
|
|
753
778
|
],
|
|
754
779
|
typeArguments: [u.suiCoinType, l.suiCoinType]
|
|
755
780
|
});
|
|
756
|
-
return [d,
|
|
781
|
+
return [d, b];
|
|
757
782
|
}
|
|
758
|
-
async function
|
|
783
|
+
async function Ne(e, r) {
|
|
759
784
|
var d;
|
|
760
|
-
const
|
|
761
|
-
...
|
|
785
|
+
const a = await ae(r), t = await S({
|
|
786
|
+
...r,
|
|
762
787
|
cacheTime: g
|
|
763
|
-
}), c = (d =
|
|
764
|
-
...
|
|
788
|
+
}), c = (d = r == null ? void 0 : r.client) != null ? d : I, n = await w({
|
|
789
|
+
...r,
|
|
765
790
|
cacheTime: g
|
|
766
791
|
}), o = new B();
|
|
767
792
|
o.moveCall({
|
|
@@ -780,60 +805,60 @@ async function Ee(e, a) {
|
|
|
780
805
|
const i = await c.devInspectTransactionBlock({
|
|
781
806
|
transactionBlock: o,
|
|
782
807
|
sender: e
|
|
783
|
-
}), u =
|
|
808
|
+
}), u = $(
|
|
784
809
|
i,
|
|
785
810
|
[
|
|
786
|
-
|
|
811
|
+
h.vector(h.string()),
|
|
787
812
|
// Asset coin types
|
|
788
|
-
|
|
813
|
+
h.vector(h.string()),
|
|
789
814
|
// Reward coin types
|
|
790
|
-
|
|
815
|
+
h.vector(h.u8()),
|
|
791
816
|
// Reward options
|
|
792
|
-
|
|
817
|
+
h.vector(h.Address),
|
|
793
818
|
// Rule IDs
|
|
794
|
-
|
|
819
|
+
h.vector(h.u256())
|
|
795
820
|
// Claimable amounts
|
|
796
821
|
]
|
|
797
822
|
), l = [];
|
|
798
823
|
if (u.length === 5 && Array.isArray(u[0])) {
|
|
799
|
-
const
|
|
800
|
-
for (let
|
|
801
|
-
const y =
|
|
802
|
-
(j) =>
|
|
803
|
-
),
|
|
804
|
-
(j) =>
|
|
824
|
+
const b = u[0].length;
|
|
825
|
+
for (let f = 0; f < b; f++) {
|
|
826
|
+
const y = a.find(
|
|
827
|
+
(j) => p(j.coinType) === p(u[1][f])
|
|
828
|
+
), C = t.find(
|
|
829
|
+
(j) => p(j.coinType) === p(u[0][f])
|
|
805
830
|
);
|
|
806
|
-
!y || !
|
|
807
|
-
assetId:
|
|
808
|
-
assetCoinType:
|
|
809
|
-
rewardCoinType:
|
|
810
|
-
option: Number(u[2][
|
|
811
|
-
userClaimableReward: Number(u[4][
|
|
812
|
-
ruleIds: Array.isArray(u[3][
|
|
831
|
+
!y || !C || l.push({
|
|
832
|
+
assetId: C.id,
|
|
833
|
+
assetCoinType: p(u[0][f]),
|
|
834
|
+
rewardCoinType: p(u[1][f]),
|
|
835
|
+
option: Number(u[2][f]),
|
|
836
|
+
userClaimableReward: Number(u[4][f]) / Math.pow(10, y.priceDecimal),
|
|
837
|
+
ruleIds: Array.isArray(u[3][f]) ? u[3][f] : [u[3][f]]
|
|
813
838
|
});
|
|
814
839
|
}
|
|
815
840
|
}
|
|
816
841
|
return l;
|
|
817
842
|
}
|
|
818
|
-
function
|
|
819
|
-
const
|
|
843
|
+
function Ee(e) {
|
|
844
|
+
const r = /* @__PURE__ */ new Map();
|
|
820
845
|
e.forEach((t) => {
|
|
821
846
|
const c = t.assetId, n = t.option, o = `${c}-${n}-${t.rewardCoinType}`;
|
|
822
|
-
|
|
847
|
+
r.has(o) ? r.get(o).total += t.userClaimableReward : r.set(o, {
|
|
823
848
|
assetId: c,
|
|
824
849
|
rewardType: n,
|
|
825
850
|
coinType: t.rewardCoinType,
|
|
826
851
|
total: Number(t.userClaimableReward)
|
|
827
852
|
});
|
|
828
853
|
});
|
|
829
|
-
const
|
|
830
|
-
for (const { assetId: t, rewardType: c, coinType: n, total: o } of
|
|
854
|
+
const a = /* @__PURE__ */ new Map();
|
|
855
|
+
for (const { assetId: t, rewardType: c, coinType: n, total: o } of r.values()) {
|
|
831
856
|
const i = `${t}-${c}`;
|
|
832
|
-
|
|
833
|
-
const u =
|
|
857
|
+
a.has(i) || a.set(i, { assetId: t, rewardType: c, rewards: /* @__PURE__ */ new Map() });
|
|
858
|
+
const u = a.get(i);
|
|
834
859
|
u.rewards.set(n, (u.rewards.get(n) || 0) + o);
|
|
835
860
|
}
|
|
836
|
-
return Array.from(
|
|
861
|
+
return Array.from(a.values()).map((t) => ({
|
|
837
862
|
assetId: t.assetId,
|
|
838
863
|
rewardType: t.rewardType,
|
|
839
864
|
rewards: Array.from(t.rewards.entries()).map(([c, n]) => ({
|
|
@@ -844,47 +869,47 @@ function Ne(e) {
|
|
|
844
869
|
}
|
|
845
870
|
const Le = _(
|
|
846
871
|
async (e) => {
|
|
847
|
-
const
|
|
848
|
-
return (await fetch(
|
|
872
|
+
const r = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}`;
|
|
873
|
+
return (await fetch(r).then((t) => t.json())).data;
|
|
849
874
|
}
|
|
850
875
|
), De = _(
|
|
851
|
-
async (e,
|
|
852
|
-
const
|
|
853
|
-
return
|
|
876
|
+
async (e, r) => {
|
|
877
|
+
const a = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${(r == null ? void 0 : r.page) || 1}&pageSize=${(r == null ? void 0 : r.size) || 400}`, t = await fetch(a).then((c) => c.json());
|
|
878
|
+
return k({
|
|
854
879
|
data: t.data.rewards
|
|
855
880
|
});
|
|
856
881
|
}
|
|
857
882
|
);
|
|
858
|
-
async function Me(e,
|
|
883
|
+
async function Me(e, r, a) {
|
|
859
884
|
var i;
|
|
860
885
|
const t = await w({
|
|
861
|
-
...
|
|
886
|
+
...a,
|
|
862
887
|
cacheTime: g
|
|
863
888
|
}), c = await S({
|
|
864
|
-
...
|
|
889
|
+
...a,
|
|
865
890
|
cacheTime: g
|
|
866
891
|
}), n = /* @__PURE__ */ new Map();
|
|
867
|
-
for (const u of
|
|
892
|
+
for (const u of r) {
|
|
868
893
|
const { rewardCoinType: l, ruleIds: d } = u;
|
|
869
|
-
for (const
|
|
894
|
+
for (const b of d) {
|
|
870
895
|
n.has(l) || n.set(l, { assetIds: [], ruleIds: [], amount: 0 });
|
|
871
|
-
const
|
|
872
|
-
|
|
896
|
+
const f = n.get(l);
|
|
897
|
+
f.assetIds.push(u.assetCoinType.replace("0x", "")), f.ruleIds.push(b), f.amount += u.userClaimableReward;
|
|
873
898
|
}
|
|
874
899
|
}
|
|
875
900
|
const o = [];
|
|
876
|
-
for (const [u, { assetIds: l, ruleIds: d, amount:
|
|
877
|
-
const
|
|
878
|
-
(
|
|
901
|
+
for (const [u, { assetIds: l, ruleIds: d, amount: b }] of n) {
|
|
902
|
+
const f = c.find(
|
|
903
|
+
(C) => p(C.suiCoinType) === p(u)
|
|
879
904
|
);
|
|
880
|
-
if (!
|
|
905
|
+
if (!f || !f.contract.rewardFundId)
|
|
881
906
|
throw new Error(`No matching rewardFund found for reward coin: ${u}`);
|
|
882
|
-
const y =
|
|
883
|
-
if (
|
|
907
|
+
const y = f.contract.rewardFundId;
|
|
908
|
+
if (a != null && a.accountCap && !a.customCoinReceive)
|
|
884
909
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
885
|
-
if (
|
|
886
|
-
let
|
|
887
|
-
|
|
910
|
+
if (a != null && a.customCoinReceive) {
|
|
911
|
+
let C;
|
|
912
|
+
a.accountCap ? C = e.moveCall({
|
|
888
913
|
target: `${t.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
889
914
|
arguments: [
|
|
890
915
|
e.object("0x06"),
|
|
@@ -899,11 +924,11 @@ async function Me(e, a, r) {
|
|
|
899
924
|
// Asset IDs
|
|
900
925
|
e.pure.vector("address", d),
|
|
901
926
|
// Rule IDs
|
|
902
|
-
|
|
927
|
+
m(a.accountCap, e.object)
|
|
903
928
|
// Account capability
|
|
904
929
|
],
|
|
905
930
|
typeArguments: [u]
|
|
906
|
-
}) :
|
|
931
|
+
}) : C = e.moveCall({
|
|
907
932
|
target: `${t.package}::incentive_v3::claim_reward`,
|
|
908
933
|
arguments: [
|
|
909
934
|
e.object("0x06"),
|
|
@@ -923,27 +948,27 @@ async function Me(e, a, r) {
|
|
|
923
948
|
});
|
|
924
949
|
const [j] = e.moveCall({
|
|
925
950
|
target: "0x2::coin::from_balance",
|
|
926
|
-
arguments: [
|
|
951
|
+
arguments: [C],
|
|
927
952
|
typeArguments: [u]
|
|
928
953
|
});
|
|
929
|
-
if ((
|
|
930
|
-
if (!
|
|
954
|
+
if ((a == null ? void 0 : a.customCoinReceive.type) === "transfer") {
|
|
955
|
+
if (!a.customCoinReceive.transfer)
|
|
931
956
|
throw new Error("customCoinReceive.transfer is required");
|
|
932
957
|
e.transferObjects(
|
|
933
958
|
[j],
|
|
934
|
-
|
|
959
|
+
m(a.customCoinReceive.transfer, e.pure.address)
|
|
935
960
|
);
|
|
936
961
|
}
|
|
937
|
-
if ((
|
|
938
|
-
const U = T(
|
|
939
|
-
U.plus(
|
|
962
|
+
if ((a == null ? void 0 : a.customCoinReceive.type) === "depositNAVI") {
|
|
963
|
+
const U = T(f.totalSupplyAmount).shiftedBy(-9), G = T(f.supplyCapCeiling).shiftedBy(-27);
|
|
964
|
+
U.plus(b).isGreaterThan(G) && ((i = a == null ? void 0 : a.customCoinReceive.depositNAVI) != null && i.fallbackReceiveAddress) ? e.transferObjects(
|
|
940
965
|
[j],
|
|
941
|
-
e.pure.address(
|
|
942
|
-
) : await x(e,
|
|
966
|
+
e.pure.address(a.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
967
|
+
) : await x(e, f, j, a);
|
|
943
968
|
} else
|
|
944
969
|
o.push({
|
|
945
970
|
coin: j,
|
|
946
|
-
identifier:
|
|
971
|
+
identifier: f
|
|
947
972
|
});
|
|
948
973
|
} else
|
|
949
974
|
e.moveCall({
|
|
@@ -967,23 +992,23 @@ async function Me(e, a, r) {
|
|
|
967
992
|
}
|
|
968
993
|
return o;
|
|
969
994
|
}
|
|
970
|
-
async function Ue(e,
|
|
971
|
-
const
|
|
972
|
-
...
|
|
995
|
+
async function Ue(e, r) {
|
|
996
|
+
const a = await w({
|
|
997
|
+
...r
|
|
973
998
|
});
|
|
974
999
|
return e.moveCall({
|
|
975
|
-
target: `${
|
|
1000
|
+
target: `${a.package}::lending::create_account`,
|
|
976
1001
|
arguments: []
|
|
977
1002
|
});
|
|
978
1003
|
}
|
|
979
1004
|
export {
|
|
980
|
-
|
|
1005
|
+
V as Address,
|
|
981
1006
|
g as DEFAULT_CACHE_TIME,
|
|
982
1007
|
ge as FlashLoanAssetConfig,
|
|
983
|
-
|
|
1008
|
+
fe as IncentiveAPYInfo,
|
|
984
1009
|
J as IncentivePoolInfo,
|
|
985
|
-
|
|
986
|
-
|
|
1010
|
+
me as IncentivePoolInfoByPhase,
|
|
1011
|
+
pe as OracleInfo,
|
|
987
1012
|
P as PoolOperator,
|
|
988
1013
|
ye as ReserveDataInfo,
|
|
989
1014
|
Q as UserStateInfo,
|
|
@@ -995,33 +1020,33 @@ export {
|
|
|
995
1020
|
Fe as flashloanPTB,
|
|
996
1021
|
F as getAllFlashLoanAssets,
|
|
997
1022
|
_e as getBorrowFee,
|
|
998
|
-
|
|
1023
|
+
Be as getCoins,
|
|
999
1024
|
w as getConfig,
|
|
1000
1025
|
he as getFees,
|
|
1001
1026
|
Se as getFlashLoanAsset,
|
|
1002
1027
|
Ie as getHealthFactor,
|
|
1003
1028
|
ee as getHealthFactorPTB,
|
|
1004
1029
|
Te as getLendingState,
|
|
1005
|
-
|
|
1030
|
+
v as getPool,
|
|
1006
1031
|
S as getPools,
|
|
1007
|
-
|
|
1032
|
+
ae as getPriceFeeds,
|
|
1008
1033
|
te as getPythStalePriceFeedId,
|
|
1009
1034
|
Ae as getSimulatedHealthFactor,
|
|
1010
1035
|
D as getSimulatedHealthFactorPTB,
|
|
1011
1036
|
we as getStats,
|
|
1012
1037
|
Pe as getTransactions,
|
|
1013
|
-
|
|
1038
|
+
Ne as getUserAvailableLendingRewards,
|
|
1014
1039
|
De as getUserClaimedRewardHistory,
|
|
1015
1040
|
Le as getUserTotalClaimedReward,
|
|
1016
|
-
|
|
1041
|
+
Re as liquidatePTB,
|
|
1017
1042
|
je as mergeCoinsPTB,
|
|
1018
|
-
|
|
1019
|
-
|
|
1043
|
+
p as normalizeCoinType,
|
|
1044
|
+
m as parseTxValue,
|
|
1020
1045
|
Ce as repayCoinPTB,
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1046
|
+
Ve as repayFlashLoanPTB,
|
|
1047
|
+
Ee as summaryLendingRewards,
|
|
1048
|
+
$e as updateOraclePricesPTB,
|
|
1049
|
+
re as updatePythPriceFeeds,
|
|
1025
1050
|
A as withCache,
|
|
1026
1051
|
_ as withSingleton,
|
|
1027
1052
|
be as withdrawCoinPTB
|