@naviprotocol/lending 1.0.4 → 1.0.6
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 +348 -340
- package/dist/index.esm.js.map +1 -1
- package/dist/reward.d.ts +6 -0
- package/dist/reward.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { Transaction as $ } from "@mysten/sui/transactions";
|
|
2
|
-
import { bcs as s, toHex as
|
|
3
|
-
import { SuiClient as
|
|
4
|
-
import
|
|
5
|
-
import { normalizeStructTag as
|
|
6
|
-
import { SuiPriceServiceConnection as E, SuiPythClient as
|
|
2
|
+
import { bcs as s, toHex as H, fromHex as q } from "@mysten/bcs";
|
|
3
|
+
import { SuiClient as z, getFullnodeUrl as O } from "@mysten/sui/client";
|
|
4
|
+
import W from "lodash.camelcase";
|
|
5
|
+
import { normalizeStructTag as K } from "@mysten/sui/utils";
|
|
6
|
+
import { SuiPriceServiceConnection as E, SuiPythClient as Y } from "@pythnetwork/pyth-sui-js";
|
|
7
7
|
import T from "bignumber.js";
|
|
8
8
|
import { bcs as b } from "@mysten/sui/bcs";
|
|
9
|
-
const
|
|
9
|
+
const R = s.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) => q(e),
|
|
12
|
+
output: (e) => H(e)
|
|
13
|
+
}), pe = s.struct("IncentiveAPYInfo", {
|
|
14
14
|
/** Asset identifier */
|
|
15
15
|
asset_id: s.u8(),
|
|
16
16
|
/** Annual Percentage Yield as a 256-bit integer */
|
|
17
17
|
apy: s.u256(),
|
|
18
18
|
/** List of supported coin types for this incentive */
|
|
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: R,
|
|
23
23
|
/** Address holding the incentive funds */
|
|
24
|
-
funds:
|
|
24
|
+
funds: R,
|
|
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 V = s.bytes(32).transform({
|
|
|
44
44
|
available: s.u256(),
|
|
45
45
|
/** Total amount of incentives */
|
|
46
46
|
total: s.u256()
|
|
47
|
-
}),
|
|
47
|
+
}), fe = s.struct("IncentivePoolInfoByPhase", {
|
|
48
48
|
/** Phase number */
|
|
49
49
|
phase: s.u64(),
|
|
50
50
|
/** List of incentive pools in this phase */
|
|
51
|
-
pools: s.vector(
|
|
52
|
-
}),
|
|
51
|
+
pools: s.vector(J)
|
|
52
|
+
}), me = s.struct("OracleInfo", {
|
|
53
53
|
/** Oracle identifier */
|
|
54
54
|
oracle_id: s.u8(),
|
|
55
55
|
/** Current price as a 256-bit integer */
|
|
@@ -58,7 +58,7 @@ const V = s.bytes(32).transform({
|
|
|
58
58
|
decimals: s.u8(),
|
|
59
59
|
/** Whether the oracle data is valid */
|
|
60
60
|
valid: s.bool()
|
|
61
|
-
}),
|
|
61
|
+
}), ge = s.struct("FlashLoanAssetConfig", {
|
|
62
62
|
/** Unique identifier for the flash loan asset */
|
|
63
63
|
id: s.string(),
|
|
64
64
|
/** Asset identifier */
|
|
@@ -75,7 +75,7 @@ const V = s.bytes(32).transform({
|
|
|
75
75
|
max: s.u64(),
|
|
76
76
|
/** Minimum flash loan amount */
|
|
77
77
|
min: s.u64()
|
|
78
|
-
}),
|
|
78
|
+
}), ye = s.struct("ReserveDataInfo", {
|
|
79
79
|
/** Reserve identifier */
|
|
80
80
|
id: s.u8(),
|
|
81
81
|
/** Oracle identifier for price feeds */
|
|
@@ -122,129 +122,129 @@ const V = s.bytes(32).transform({
|
|
|
122
122
|
liquidation_bonus: s.u256(),
|
|
123
123
|
/** Liquidation threshold */
|
|
124
124
|
liquidation_threshold: s.u256()
|
|
125
|
-
}),
|
|
125
|
+
}), Q = s.struct("UserStateInfo", {
|
|
126
126
|
/** Asset identifier */
|
|
127
127
|
asset_id: s.u8(),
|
|
128
128
|
/** User's current borrow balance */
|
|
129
129
|
borrow_balance: s.u256(),
|
|
130
130
|
/** User's current supply balance */
|
|
131
131
|
supply_balance: s.u256()
|
|
132
|
-
}),
|
|
133
|
-
url:
|
|
132
|
+
}), I = new z({
|
|
133
|
+
url: O("mainnet")
|
|
134
134
|
});
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
return e.forEach((
|
|
135
|
+
function N(e) {
|
|
136
|
+
const a = [];
|
|
137
|
+
return e.forEach((r, 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 r == "object" && c) {
|
|
140
|
+
const { client: n, disableCache: o, cacheTime: i, ...u } = r;
|
|
141
|
+
a.push(u);
|
|
142
142
|
} else
|
|
143
|
-
|
|
144
|
-
}), JSON.stringify(
|
|
145
|
-
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
return (...
|
|
149
|
-
const t =
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
})),
|
|
143
|
+
a.push(r);
|
|
144
|
+
}), JSON.stringify(a);
|
|
145
|
+
}
|
|
146
|
+
function _(e) {
|
|
147
|
+
const a = {};
|
|
148
|
+
return (...r) => {
|
|
149
|
+
const t = N(r);
|
|
150
|
+
return a[t] || (a[t] = e(...r).finally(() => {
|
|
151
|
+
a[t] = null;
|
|
152
|
+
})), a[t];
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function
|
|
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(...
|
|
155
|
+
function A(e) {
|
|
156
|
+
let a = {};
|
|
157
|
+
return (...r) => {
|
|
158
|
+
const t = r[r.length - 1], c = N(r), n = a[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(...r).then((o) => (a[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
|
-
[
|
|
165
|
+
function B(e) {
|
|
166
|
+
return Array.isArray(e) ? e.map((a) => B(a)) : e != null && typeof e == "object" ? Object.keys(e).reduce(
|
|
167
|
+
(a, r) => ({
|
|
168
|
+
...a,
|
|
169
|
+
[W(r)]: B(e[r])
|
|
170
170
|
}),
|
|
171
171
|
{}
|
|
172
172
|
) : e;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
return typeof e == "object" ? e :
|
|
174
|
+
function f(e, a) {
|
|
175
|
+
return typeof e == "object" ? e : a(e);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
178
|
-
return typeof
|
|
177
|
+
function X(e, a) {
|
|
178
|
+
return typeof a == "string" ? e.object(a) : typeof a == "object" && a.$kind ? a : e.object(a.contract.pool);
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function k(e, a, r) {
|
|
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) => (a[c] || a[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
188
|
function m(e) {
|
|
189
|
-
return
|
|
189
|
+
return K(e);
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
const
|
|
193
|
-
return
|
|
191
|
+
function L(e) {
|
|
192
|
+
const a = (e || 0) / Math.pow(10, 27);
|
|
193
|
+
return a > Math.pow(10, 5) ? 1 / 0 : a;
|
|
194
194
|
}
|
|
195
195
|
new E("https://hermes.pyth.network", {
|
|
196
196
|
timeout: 2e4
|
|
197
197
|
});
|
|
198
|
-
const
|
|
199
|
-
if (!Number(e) || !Number(
|
|
200
|
-
const
|
|
201
|
-
return new T(e).multipliedBy(new T(
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
return (await fetch(
|
|
198
|
+
const Z = 27, V = (e, a) => {
|
|
199
|
+
if (!Number(e) || !Number(a)) return new T(0);
|
|
200
|
+
const r = new T(1).shiftedBy(1 * Z), t = r.multipliedBy(new T(0.5));
|
|
201
|
+
return new T(e).multipliedBy(new T(a)).plus(t).dividedBy(r).integerValue(T.ROUND_DOWN);
|
|
202
|
+
}, w = A(
|
|
203
|
+
_(async (e) => {
|
|
204
|
+
const a = `https://open-api.naviprotocol.io/api/navi/config?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
205
|
+
return (await fetch(a).then((t) => t.json())).data;
|
|
206
206
|
})
|
|
207
207
|
), g = 1e3 * 60 * 5;
|
|
208
|
-
var
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
return (await fetch(
|
|
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
|
+
const S = A(
|
|
210
|
+
_(async (e) => {
|
|
211
|
+
const a = `https://open-api.naviprotocol.io/api/navi/pools?env=${(e == null ? void 0 : e.env) || "prod"}`;
|
|
212
|
+
return (await fetch(a).then((t) => t.json())).data;
|
|
213
213
|
})
|
|
214
214
|
);
|
|
215
|
-
async function
|
|
216
|
-
const
|
|
217
|
-
...
|
|
215
|
+
async function C(e, a) {
|
|
216
|
+
const r = await S({
|
|
217
|
+
...a,
|
|
218
218
|
cacheTime: g
|
|
219
219
|
});
|
|
220
220
|
if (typeof e == "object")
|
|
221
221
|
return e;
|
|
222
|
-
const t =
|
|
222
|
+
const t = r.find((c) => typeof e == "string" ? m(c.suiCoinType) === m(e) : typeof e == "number" ? c.id === e : !1);
|
|
223
223
|
if (!t)
|
|
224
224
|
throw new Error("Pool not found");
|
|
225
225
|
return t;
|
|
226
226
|
}
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
),
|
|
230
|
-
|
|
227
|
+
const we = A(
|
|
228
|
+
_(async (e) => (await fetch("https://open-api.naviprotocol.io/api/navi/stats").then((t) => t.json())).data)
|
|
229
|
+
), he = A(
|
|
230
|
+
_(
|
|
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
|
|
235
|
-
const c = await
|
|
234
|
+
async function x(e, a, r, t) {
|
|
235
|
+
const c = await w({
|
|
236
236
|
...t,
|
|
237
237
|
cacheTime: g
|
|
238
|
-
}), n = await
|
|
238
|
+
}), n = await C(a, t), o = typeof r == "object" && r.$kind === "GasCoin";
|
|
239
239
|
if (m(n.suiCoinType) === m("0x2::sui::SUI") && o) {
|
|
240
240
|
if (!(t != null && t.amount))
|
|
241
241
|
throw new Error("Amount is required for sui coin");
|
|
242
|
-
|
|
242
|
+
r = e.splitCoins(r, [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 = f(t.amount, e.pure.u64) : i = e.moveCall({
|
|
246
246
|
target: "0x2::coin::value",
|
|
247
|
-
arguments: [
|
|
247
|
+
arguments: [f(r, 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, r, a, t) {
|
|
|
253
253
|
e.object(c.storage),
|
|
254
254
|
e.object(n.contract.pool),
|
|
255
255
|
e.pure.u8(n.id),
|
|
256
|
-
|
|
256
|
+
f(r, e.object),
|
|
257
257
|
e.object(c.incentiveV2),
|
|
258
258
|
e.object(c.incentiveV3),
|
|
259
|
-
|
|
259
|
+
f(t.accountCap, e.object)
|
|
260
260
|
],
|
|
261
261
|
typeArguments: [n.suiCoinType]
|
|
262
262
|
}) : e.moveCall({
|
|
@@ -266,7 +266,7 @@ async function X(e, r, a, t) {
|
|
|
266
266
|
e.object(c.storage),
|
|
267
267
|
e.object(n.contract.pool),
|
|
268
268
|
e.pure.u8(n.id),
|
|
269
|
-
|
|
269
|
+
f(r, e.object),
|
|
270
270
|
i,
|
|
271
271
|
e.object(c.incentiveV2),
|
|
272
272
|
e.object(c.incentiveV3)
|
|
@@ -274,11 +274,11 @@ async function X(e, r, a, t) {
|
|
|
274
274
|
typeArguments: [n.suiCoinType]
|
|
275
275
|
}), e;
|
|
276
276
|
}
|
|
277
|
-
async function
|
|
278
|
-
const c = await
|
|
277
|
+
async function be(e, a, r, t) {
|
|
278
|
+
const c = await w({
|
|
279
279
|
...t,
|
|
280
280
|
cacheTime: g
|
|
281
|
-
}), n = await
|
|
281
|
+
}), n = await C(a, t), o = f(r, e.pure.u64);
|
|
282
282
|
let i;
|
|
283
283
|
if (t != null && t.accountCap) {
|
|
284
284
|
const [l] = e.moveCall({
|
|
@@ -292,7 +292,7 @@ async function we(e, r, a, t) {
|
|
|
292
292
|
o,
|
|
293
293
|
e.object(c.incentiveV2),
|
|
294
294
|
e.object(c.incentiveV3),
|
|
295
|
-
|
|
295
|
+
f(t.accountCap, e.object)
|
|
296
296
|
],
|
|
297
297
|
typeArguments: [n.suiCoinType]
|
|
298
298
|
});
|
|
@@ -320,11 +320,11 @@ async function we(e, r, a, t) {
|
|
|
320
320
|
typeArguments: [n.suiCoinType]
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
|
-
async function
|
|
324
|
-
const c = await
|
|
323
|
+
async function ve(e, a, r, t) {
|
|
324
|
+
const c = await w({
|
|
325
325
|
...t,
|
|
326
326
|
cacheTime: g
|
|
327
|
-
}), n = await
|
|
327
|
+
}), n = await C(a, t), o = f(r, e.pure.u64);
|
|
328
328
|
let i;
|
|
329
329
|
if (t != null && t.accountCap) {
|
|
330
330
|
const [l] = e.moveCall({
|
|
@@ -338,7 +338,7 @@ async function he(e, r, a, t) {
|
|
|
338
338
|
o,
|
|
339
339
|
e.object(c.incentiveV2),
|
|
340
340
|
e.object(c.incentiveV3),
|
|
341
|
-
|
|
341
|
+
f(t.accountCap, e.object)
|
|
342
342
|
],
|
|
343
343
|
typeArguments: [n.suiCoinType]
|
|
344
344
|
});
|
|
@@ -366,20 +366,20 @@ async function he(e, r, a, t) {
|
|
|
366
366
|
typeArguments: [n.suiCoinType]
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
-
async function
|
|
370
|
-
const c = await
|
|
369
|
+
async function Ce(e, a, r, t) {
|
|
370
|
+
const c = await w({
|
|
371
371
|
...t,
|
|
372
372
|
cacheTime: g
|
|
373
|
-
}), n = await
|
|
373
|
+
}), n = await C(a, t), o = typeof r == "object" && r.$kind === "GasCoin";
|
|
374
374
|
if (m(n.suiCoinType) === m("0x2::sui::SUI") && o) {
|
|
375
375
|
if (!(t != null && t.amount))
|
|
376
376
|
throw new Error("Amount is required for sui coin");
|
|
377
|
-
|
|
377
|
+
r = e.splitCoins(r, [t.amount]);
|
|
378
378
|
}
|
|
379
379
|
let i;
|
|
380
|
-
return typeof (t == null ? void 0 : t.amount) != "undefined" ? i =
|
|
380
|
+
return typeof (t == null ? void 0 : t.amount) != "undefined" ? i = f(t.amount, e.pure.u64) : i = e.moveCall({
|
|
381
381
|
target: "0x2::coin::value",
|
|
382
|
-
arguments: [
|
|
382
|
+
arguments: [f(r, e.object)],
|
|
383
383
|
typeArguments: [n.suiCoinType]
|
|
384
384
|
}), t != null && t.accountCap ? e.moveCall({
|
|
385
385
|
target: `${c.package}::incentive_v3::repay_with_account_cap`,
|
|
@@ -389,11 +389,11 @@ async function be(e, r, a, t) {
|
|
|
389
389
|
e.object(c.storage),
|
|
390
390
|
e.object(n.contract.pool),
|
|
391
391
|
e.pure.u8(n.id),
|
|
392
|
-
|
|
392
|
+
f(r, e.object),
|
|
393
393
|
i,
|
|
394
394
|
e.object(c.incentiveV2),
|
|
395
395
|
e.object(c.incentiveV3),
|
|
396
|
-
|
|
396
|
+
f(t.accountCap, e.object)
|
|
397
397
|
],
|
|
398
398
|
typeArguments: [n.suiCoinType]
|
|
399
399
|
}) : e.moveCall({
|
|
@@ -404,7 +404,7 @@ async function be(e, r, a, t) {
|
|
|
404
404
|
e.object(c.storage),
|
|
405
405
|
e.object(n.contract.pool),
|
|
406
406
|
e.pure.u8(n.id),
|
|
407
|
-
|
|
407
|
+
f(r, e.object),
|
|
408
408
|
i,
|
|
409
409
|
e.object(c.incentiveV2),
|
|
410
410
|
e.object(c.incentiveV3)
|
|
@@ -412,23 +412,23 @@ async function be(e, r, a, t) {
|
|
|
412
412
|
typeArguments: [n.suiCoinType]
|
|
413
413
|
}), e;
|
|
414
414
|
}
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
const
|
|
415
|
+
const _e = A(
|
|
416
|
+
_(async (e) => {
|
|
417
|
+
const a = await w({
|
|
418
418
|
...e
|
|
419
|
-
}), t = (await
|
|
420
|
-
id:
|
|
419
|
+
}), t = (await I.getObject({
|
|
420
|
+
id: a.incentiveV3,
|
|
421
421
|
options: { showType: !0, showOwner: !0, showContent: !0 }
|
|
422
422
|
})).data.content.fields.borrow_fee_rate;
|
|
423
423
|
return Number(t) / 100;
|
|
424
424
|
})
|
|
425
425
|
);
|
|
426
|
-
function
|
|
427
|
-
const t = typeof (
|
|
426
|
+
function je(e, a, r) {
|
|
427
|
+
const t = typeof (r == null ? void 0 : r.balance) == "number", c = t ? r.balance : 0;
|
|
428
428
|
let n = 0;
|
|
429
429
|
const o = [];
|
|
430
430
|
let i = "";
|
|
431
|
-
if (
|
|
431
|
+
if (a.sort((l, d) => Number(d.balance) - Number(l.balance)).forEach((l) => {
|
|
432
432
|
if (!(t && n >= c) && Number(l.balance) !== 0) {
|
|
433
433
|
if (i || (i = l.coinType), i !== l.coinType)
|
|
434
434
|
throw new Error("All coins must be of the same type");
|
|
@@ -440,86 +440,86 @@ function Ce(e, r, a) {
|
|
|
440
440
|
throw new Error(
|
|
441
441
|
`Balance is less than the specified balance: ${n} < ${c}`
|
|
442
442
|
);
|
|
443
|
-
if (m(i) === m("0x2::sui::SUI") && (
|
|
443
|
+
if (m(i) === m("0x2::sui::SUI") && (r != null && r.useGasCoin))
|
|
444
444
|
return t ? e.splitCoins(e.gas, [e.pure.u64(c)]) : e.gas;
|
|
445
445
|
const u = o.length === 1 ? e.object(o[0]) : e.mergeCoins(o[0], o.slice(1));
|
|
446
446
|
return t ? e.splitCoins(u, [e.pure.u64(c)]) : u;
|
|
447
447
|
}
|
|
448
|
-
async function D(e,
|
|
449
|
-
const i = await
|
|
448
|
+
async function D(e, a, r, t, c, n, o) {
|
|
449
|
+
const i = await w({
|
|
450
450
|
...o,
|
|
451
451
|
cacheTime: g
|
|
452
|
-
}), u = await
|
|
452
|
+
}), u = await C(r, o);
|
|
453
453
|
return e.moveCall({
|
|
454
454
|
target: `${i.uiGetter}::calculator_unchecked::dynamic_health_factor`,
|
|
455
455
|
arguments: [
|
|
456
456
|
e.object("0x06"),
|
|
457
457
|
e.object(i.storage),
|
|
458
458
|
e.object(i.oracle.priceOracle),
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
459
|
+
X(e, u),
|
|
460
|
+
f(a, e.pure.address),
|
|
461
|
+
f(u.id, e.pure.u8),
|
|
462
|
+
f(t, e.pure.u64),
|
|
463
|
+
f(c, e.pure.u64),
|
|
464
|
+
f(n, e.pure.bool)
|
|
465
465
|
],
|
|
466
466
|
typeArguments: [u.suiCoinType]
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
|
-
async function
|
|
470
|
-
return D(e,
|
|
469
|
+
async function ee(e, a, r) {
|
|
470
|
+
return D(e, a, 0, 0, 0, !1, r);
|
|
471
471
|
}
|
|
472
|
-
const
|
|
473
|
-
async (e,
|
|
472
|
+
const Te = A(
|
|
473
|
+
async (e, a) => {
|
|
474
474
|
var l;
|
|
475
|
-
const
|
|
476
|
-
...
|
|
475
|
+
const r = await w({
|
|
476
|
+
...a,
|
|
477
477
|
cacheTime: g
|
|
478
|
-
}), t = new $(), c = (l =
|
|
478
|
+
}), t = new $(), c = (l = a == null ? void 0 : a.client) != null ? l : I, n = await S(a);
|
|
479
479
|
t.moveCall({
|
|
480
|
-
target: `${
|
|
481
|
-
arguments: [t.object(
|
|
480
|
+
target: `${r.uiGetter}::getter_unchecked::get_user_state`,
|
|
481
|
+
arguments: [t.object(r.storage), t.pure.address(e)]
|
|
482
482
|
});
|
|
483
483
|
const o = await c.devInspectTransactionBlock({
|
|
484
484
|
transactionBlock: t,
|
|
485
485
|
sender: e
|
|
486
|
-
}), i =
|
|
487
|
-
return
|
|
486
|
+
}), i = k(o, [b.vector(Q)]);
|
|
487
|
+
return B(
|
|
488
488
|
i[0].filter((d) => d.supply_balance !== "0" || d.borrow_balance !== "0")
|
|
489
489
|
).map((d) => {
|
|
490
|
-
const
|
|
490
|
+
const h = n.find((v) => v.id === d.assetId), p = V(
|
|
491
491
|
d.supplyBalance,
|
|
492
|
-
|
|
493
|
-
).toString(), y =
|
|
492
|
+
h.currentSupplyIndex
|
|
493
|
+
).toString(), y = V(
|
|
494
494
|
d.borrowBalance,
|
|
495
|
-
|
|
495
|
+
h.currentBorrowIndex
|
|
496
496
|
).toString();
|
|
497
497
|
return {
|
|
498
498
|
...d,
|
|
499
|
-
supplyBalance:
|
|
499
|
+
supplyBalance: p,
|
|
500
500
|
borrowBalance: y,
|
|
501
|
-
pool:
|
|
501
|
+
pool: h
|
|
502
502
|
};
|
|
503
503
|
}).filter((d) => !!d.pool);
|
|
504
504
|
}
|
|
505
505
|
);
|
|
506
|
-
async function
|
|
506
|
+
async function Ie(e, a) {
|
|
507
507
|
var o;
|
|
508
|
-
const
|
|
509
|
-
await
|
|
510
|
-
const c = await
|
|
508
|
+
const r = (o = a == null ? void 0 : a.client) != null ? o : I, t = new $();
|
|
509
|
+
await ee(t, e, a);
|
|
510
|
+
const c = await r.devInspectTransactionBlock({
|
|
511
511
|
transactionBlock: t,
|
|
512
512
|
sender: e
|
|
513
|
-
}), n =
|
|
514
|
-
return
|
|
513
|
+
}), n = k(c, [b.u256()]);
|
|
514
|
+
return L(Number(n[0]) || 0);
|
|
515
515
|
}
|
|
516
|
-
async function
|
|
517
|
-
var
|
|
518
|
-
const c = (
|
|
516
|
+
async function Ae(e, a, r, t) {
|
|
517
|
+
var p;
|
|
518
|
+
const c = (p = t == null ? void 0 : t.client) != null ? p : I, n = new $();
|
|
519
519
|
let o = 0, i = 0;
|
|
520
|
-
const u = await
|
|
521
|
-
if (
|
|
522
|
-
y.type ===
|
|
520
|
+
const u = await C(a, t);
|
|
521
|
+
if (r.forEach((y) => {
|
|
522
|
+
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);
|
|
523
523
|
}), o * i < 0)
|
|
524
524
|
throw new Error("Invalid operations");
|
|
525
525
|
const l = o > 0 || i > 0;
|
|
@@ -535,47 +535,47 @@ async function Te(e, r, a, t) {
|
|
|
535
535
|
const d = await c.devInspectTransactionBlock({
|
|
536
536
|
transactionBlock: n,
|
|
537
537
|
sender: e
|
|
538
|
-
}),
|
|
539
|
-
return
|
|
540
|
-
}
|
|
541
|
-
const
|
|
542
|
-
async (e,
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${
|
|
538
|
+
}), h = k(d, [b.u256()]);
|
|
539
|
+
return L(Number(h[0]) || 0);
|
|
540
|
+
}
|
|
541
|
+
const Pe = _(
|
|
542
|
+
async (e, a) => {
|
|
543
|
+
const r = new URLSearchParams();
|
|
544
|
+
a != null && a.cursor && r.set("cursor", a.cursor), r.set("userAddress", e);
|
|
545
|
+
const t = `https://open-api.naviprotocol.io/api/navi/user/transactions?${r.toString()}`;
|
|
546
546
|
return (await fetch(t).then((n) => n.json())).data;
|
|
547
547
|
}
|
|
548
548
|
);
|
|
549
|
-
async function
|
|
549
|
+
async function Be(e, a) {
|
|
550
550
|
var n;
|
|
551
|
-
let
|
|
552
|
-
const t = [], c = (n =
|
|
551
|
+
let r = null;
|
|
552
|
+
const t = [], c = (n = a == null ? void 0 : a.client) != null ? n : I;
|
|
553
553
|
do {
|
|
554
554
|
let o;
|
|
555
|
-
if (
|
|
555
|
+
if (a != null && a.coinType ? o = await c.getCoins({
|
|
556
556
|
owner: e,
|
|
557
|
-
coinType:
|
|
558
|
-
cursor:
|
|
557
|
+
coinType: a == null ? void 0 : a.coinType,
|
|
558
|
+
cursor: r,
|
|
559
559
|
limit: 100
|
|
560
560
|
}) : o = await c.getAllCoins({
|
|
561
561
|
owner: e,
|
|
562
|
-
cursor:
|
|
562
|
+
cursor: r,
|
|
563
563
|
limit: 100
|
|
564
564
|
}), !o.data || !o.data.length)
|
|
565
565
|
break;
|
|
566
|
-
t.push(...o.data),
|
|
567
|
-
} while (
|
|
566
|
+
t.push(...o.data), r = o.nextCursor;
|
|
567
|
+
} while (r);
|
|
568
568
|
return t;
|
|
569
569
|
}
|
|
570
570
|
const M = new E("https://hermes.pyth.network", {
|
|
571
571
|
timeout: 1e4
|
|
572
572
|
});
|
|
573
|
-
async function
|
|
573
|
+
async function te(e) {
|
|
574
574
|
try {
|
|
575
|
-
const
|
|
576
|
-
if (!
|
|
575
|
+
const a = [], r = await M.getLatestPriceFeeds(e);
|
|
576
|
+
if (!r) return a;
|
|
577
577
|
const t = Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3);
|
|
578
|
-
for (const c of
|
|
578
|
+
for (const c of r) {
|
|
579
579
|
const n = c.getPriceUnchecked();
|
|
580
580
|
if (n.publishTime > t) {
|
|
581
581
|
console.warn(
|
|
@@ -585,44 +585,44 @@ async function x(e) {
|
|
|
585
585
|
}
|
|
586
586
|
t - c.getPriceUnchecked().publishTime > 30 && (console.info(
|
|
587
587
|
`stale price feed, id: ${c.id}, publish time: ${n.publishTime}, current timestamp: ${t}`
|
|
588
|
-
),
|
|
588
|
+
), a.push(c.id));
|
|
589
589
|
}
|
|
590
|
-
return
|
|
591
|
-
} catch (
|
|
592
|
-
throw new Error(`failed to get pyth stale price feed id, msg: ${
|
|
590
|
+
return a;
|
|
591
|
+
} catch (a) {
|
|
592
|
+
throw new Error(`failed to get pyth stale price feed id, msg: ${a.message}`);
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
async function
|
|
595
|
+
async function ae(e, a, r) {
|
|
596
596
|
var n;
|
|
597
|
-
const t = (n =
|
|
598
|
-
...
|
|
597
|
+
const t = (n = r == null ? void 0 : r.client) != null ? n : I, c = await w({
|
|
598
|
+
...r,
|
|
599
599
|
cacheTime: g
|
|
600
600
|
});
|
|
601
601
|
try {
|
|
602
|
-
const o = await M.getPriceFeedsUpdateData(
|
|
603
|
-
return await new
|
|
602
|
+
const o = await M.getPriceFeedsUpdateData(a);
|
|
603
|
+
return await new Y(
|
|
604
604
|
t,
|
|
605
605
|
c.oracle.pythStateId,
|
|
606
606
|
c.oracle.wormholeStateId
|
|
607
|
-
).updatePriceFeeds(e, o,
|
|
607
|
+
).updatePriceFeeds(e, o, a);
|
|
608
608
|
} catch (o) {
|
|
609
609
|
throw new Error(`failed to update pyth price feeds, msg: ${o.message}`);
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
|
-
async function
|
|
613
|
-
const t = await
|
|
614
|
-
...
|
|
612
|
+
async function $e(e, a, r) {
|
|
613
|
+
const t = await w({
|
|
614
|
+
...r,
|
|
615
615
|
cacheTime: g
|
|
616
616
|
});
|
|
617
|
-
if (
|
|
618
|
-
const c =
|
|
617
|
+
if (r != null && r.updatePythPriceFeeds) {
|
|
618
|
+
const c = a.filter((n) => !!n.pythPriceFeedId).map((n) => n.pythPriceFeedId);
|
|
619
619
|
try {
|
|
620
|
-
const n = await
|
|
621
|
-
n.length > 0 && await
|
|
620
|
+
const n = await te(c);
|
|
621
|
+
n.length > 0 && await ae(e, n, r);
|
|
622
622
|
} catch {
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
for (const c of
|
|
625
|
+
for (const c of a)
|
|
626
626
|
e.moveCall({
|
|
627
627
|
target: `${t.oracle.packageId}::oracle_pro::update_single_price`,
|
|
628
628
|
arguments: [
|
|
@@ -642,32 +642,32 @@ async function Pe(e, r, a) {
|
|
|
642
642
|
});
|
|
643
643
|
return e;
|
|
644
644
|
}
|
|
645
|
-
async function
|
|
646
|
-
return (await
|
|
645
|
+
async function re(e) {
|
|
646
|
+
return (await w({
|
|
647
647
|
...e,
|
|
648
648
|
cacheTime: g
|
|
649
649
|
})).oracle.feeds;
|
|
650
650
|
}
|
|
651
|
-
function
|
|
652
|
-
return e.filter((
|
|
651
|
+
function ke(e, a) {
|
|
652
|
+
return e.filter((r) => !!(a != null && a.lendingState && a.lendingState.find((c) => c.assetId === r.assetId) || a != null && a.pools && a.pools.find((c) => c.id === r.assetId)));
|
|
653
653
|
}
|
|
654
|
-
const F =
|
|
655
|
-
|
|
656
|
-
const
|
|
657
|
-
return Object.keys(
|
|
658
|
-
...
|
|
654
|
+
const F = A(
|
|
655
|
+
_(async (e) => {
|
|
656
|
+
const a = `https://open-api.naviprotocol.io/api/navi/flashloan?env=${(e == null ? void 0 : e.env) || "prod"}`, r = await fetch(a).then((t) => t.json());
|
|
657
|
+
return Object.keys(r.data).map((t) => ({
|
|
658
|
+
...r.data[t],
|
|
659
659
|
coinType: t
|
|
660
660
|
}));
|
|
661
661
|
})
|
|
662
662
|
);
|
|
663
|
-
async function
|
|
664
|
-
return (await F(
|
|
663
|
+
async function Se(e, a) {
|
|
664
|
+
return (await F(a)).find((t) => typeof e == "string" ? m(t.coinType) === m(e) : typeof e == "number" ? t.assetId === e : t.assetId === e.id) || null;
|
|
665
665
|
}
|
|
666
|
-
async function
|
|
667
|
-
const c = await
|
|
666
|
+
async function Fe(e, a, r, t) {
|
|
667
|
+
const c = await w({
|
|
668
668
|
...t,
|
|
669
669
|
cacheTime: g
|
|
670
|
-
}), n = await
|
|
670
|
+
}), n = await C(a, t);
|
|
671
671
|
if (!(await F({
|
|
672
672
|
...t,
|
|
673
673
|
cacheTime: g
|
|
@@ -680,17 +680,17 @@ async function ke(e, r, a, t) {
|
|
|
680
680
|
arguments: [
|
|
681
681
|
e.object(c.flashloanConfig),
|
|
682
682
|
e.object(n.contract.pool),
|
|
683
|
-
|
|
683
|
+
f(r, e.pure.u64)
|
|
684
684
|
],
|
|
685
685
|
typeArguments: [n.suiCoinType]
|
|
686
686
|
});
|
|
687
687
|
return [u, l];
|
|
688
688
|
}
|
|
689
|
-
async function
|
|
690
|
-
const n = await
|
|
689
|
+
async function Re(e, a, r, t, c) {
|
|
690
|
+
const n = await w({
|
|
691
691
|
...c,
|
|
692
692
|
cacheTime: g
|
|
693
|
-
}), o = await
|
|
693
|
+
}), o = await C(a, c);
|
|
694
694
|
if (!(await F({
|
|
695
695
|
...c,
|
|
696
696
|
cacheTime: g
|
|
@@ -704,18 +704,18 @@ async function Se(e, r, a, t, c) {
|
|
|
704
704
|
e.object("0x06"),
|
|
705
705
|
e.object(n.storage),
|
|
706
706
|
e.object(o.contract.pool),
|
|
707
|
-
|
|
708
|
-
|
|
707
|
+
f(r, e.object),
|
|
708
|
+
f(t, e.object)
|
|
709
709
|
],
|
|
710
710
|
typeArguments: [o.suiCoinType]
|
|
711
711
|
});
|
|
712
712
|
return [l];
|
|
713
713
|
}
|
|
714
|
-
async function
|
|
714
|
+
async function Ve(e, a, r, t, c, n) {
|
|
715
715
|
const o = {
|
|
716
716
|
...n,
|
|
717
717
|
cacheTime: g
|
|
718
|
-
}, i = await
|
|
718
|
+
}, i = await w(o), u = await C(a, o), l = await C(t, o), [d, h] = e.moveCall({
|
|
719
719
|
target: `${i.package}::incentive_v3::liquidation`,
|
|
720
720
|
arguments: [
|
|
721
721
|
e.object("0x06"),
|
|
@@ -728,13 +728,13 @@ async function Fe(e, r, a, t, c, n) {
|
|
|
728
728
|
// Pay asset ID
|
|
729
729
|
e.object(u.contract.pool),
|
|
730
730
|
// Pay asset pool contract
|
|
731
|
-
|
|
731
|
+
f(r, e.object),
|
|
732
732
|
// Debt repayment amount
|
|
733
733
|
e.pure.u8(l.id),
|
|
734
734
|
// Collateral asset ID
|
|
735
735
|
e.object(l.contract.pool),
|
|
736
736
|
// Collateral asset pool contract
|
|
737
|
-
|
|
737
|
+
f(c, e.pure.address),
|
|
738
738
|
// Borrower address
|
|
739
739
|
e.object(i.incentiveV2),
|
|
740
740
|
// Incentive V2 contract
|
|
@@ -743,12 +743,12 @@ async function Fe(e, r, a, t, c, n) {
|
|
|
743
743
|
],
|
|
744
744
|
typeArguments: [u.suiCoinType, l.suiCoinType]
|
|
745
745
|
});
|
|
746
|
-
return [d,
|
|
746
|
+
return [d, h];
|
|
747
747
|
}
|
|
748
|
-
async function
|
|
748
|
+
async function Ee(e, a) {
|
|
749
749
|
var d;
|
|
750
|
-
const
|
|
751
|
-
...
|
|
750
|
+
const r = await re(a), t = await S(a), c = (d = a == null ? void 0 : a.client) != null ? d : I, n = await w({
|
|
751
|
+
...a,
|
|
752
752
|
cacheTime: g
|
|
753
753
|
}), o = new $();
|
|
754
754
|
o.moveCall({
|
|
@@ -767,7 +767,7 @@ async function Ve(e, r) {
|
|
|
767
767
|
const i = await c.devInspectTransactionBlock({
|
|
768
768
|
transactionBlock: o,
|
|
769
769
|
sender: e
|
|
770
|
-
}), u =
|
|
770
|
+
}), u = k(
|
|
771
771
|
i,
|
|
772
772
|
[
|
|
773
773
|
b.vector(b.string()),
|
|
@@ -783,44 +783,44 @@ async function Ve(e, r) {
|
|
|
783
783
|
]
|
|
784
784
|
), l = [];
|
|
785
785
|
if (u.length === 5 && Array.isArray(u[0])) {
|
|
786
|
-
const
|
|
787
|
-
for (let
|
|
788
|
-
const y =
|
|
789
|
-
(
|
|
790
|
-
),
|
|
791
|
-
(
|
|
786
|
+
const h = u[0].length;
|
|
787
|
+
for (let p = 0; p < h; p++) {
|
|
788
|
+
const y = r.find(
|
|
789
|
+
(j) => m(j.coinType) === m(u[1][p])
|
|
790
|
+
), v = t.find(
|
|
791
|
+
(j) => m(j.coinType) === m(u[0][p])
|
|
792
792
|
);
|
|
793
|
-
!y || !
|
|
794
|
-
assetId:
|
|
795
|
-
assetCoinType: m(u[0][
|
|
796
|
-
rewardCoinType: m(u[1][
|
|
797
|
-
option: Number(u[2][
|
|
798
|
-
userClaimableReward: Number(u[4][
|
|
799
|
-
ruleIds: Array.isArray(u[3][
|
|
793
|
+
!y || !v || l.push({
|
|
794
|
+
assetId: v.id,
|
|
795
|
+
assetCoinType: m(u[0][p]),
|
|
796
|
+
rewardCoinType: m(u[1][p]),
|
|
797
|
+
option: Number(u[2][p]),
|
|
798
|
+
userClaimableReward: Number(u[4][p]) / Math.pow(10, y.priceDecimal),
|
|
799
|
+
ruleIds: Array.isArray(u[3][p]) ? u[3][p] : [u[3][p]]
|
|
800
800
|
});
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
return l;
|
|
804
804
|
}
|
|
805
|
-
function
|
|
806
|
-
const
|
|
805
|
+
function Ne(e) {
|
|
806
|
+
const a = /* @__PURE__ */ new Map();
|
|
807
807
|
e.forEach((t) => {
|
|
808
808
|
const c = t.assetId, n = t.option, o = `${c}-${n}-${t.rewardCoinType}`;
|
|
809
|
-
|
|
809
|
+
a.has(o) ? a.get(o).total += t.userClaimableReward : a.set(o, {
|
|
810
810
|
assetId: c,
|
|
811
811
|
rewardType: n,
|
|
812
812
|
coinType: t.rewardCoinType,
|
|
813
813
|
total: Number(t.userClaimableReward)
|
|
814
814
|
});
|
|
815
815
|
});
|
|
816
|
-
const
|
|
817
|
-
for (const { assetId: t, rewardType: c, coinType: n, total: o } of
|
|
816
|
+
const r = /* @__PURE__ */ new Map();
|
|
817
|
+
for (const { assetId: t, rewardType: c, coinType: n, total: o } of a.values()) {
|
|
818
818
|
const i = `${t}-${c}`;
|
|
819
|
-
|
|
820
|
-
const u =
|
|
819
|
+
r.has(i) || r.set(i, { assetId: t, rewardType: c, rewards: /* @__PURE__ */ new Map() });
|
|
820
|
+
const u = r.get(i);
|
|
821
821
|
u.rewards.set(n, (u.rewards.get(n) || 0) + o);
|
|
822
822
|
}
|
|
823
|
-
return Array.from(
|
|
823
|
+
return Array.from(r.values()).map((t) => ({
|
|
824
824
|
assetId: t.assetId,
|
|
825
825
|
rewardType: t.rewardType,
|
|
826
826
|
rewards: Array.from(t.rewards.entries()).map(([c, n]) => ({
|
|
@@ -829,48 +829,49 @@ function Re(e) {
|
|
|
829
829
|
}))
|
|
830
830
|
}));
|
|
831
831
|
}
|
|
832
|
-
const
|
|
832
|
+
const Le = _(
|
|
833
833
|
async (e) => {
|
|
834
|
-
const
|
|
835
|
-
return (await fetch(
|
|
834
|
+
const a = `https://open-api.naviprotocol.io/api/navi/user/total_claimed_reward?userAddress=${e}`;
|
|
835
|
+
return (await fetch(a).then((t) => t.json())).data;
|
|
836
836
|
}
|
|
837
|
-
),
|
|
838
|
-
async (e,
|
|
839
|
-
const
|
|
840
|
-
return
|
|
837
|
+
), De = _(
|
|
838
|
+
async (e, a) => {
|
|
839
|
+
const r = `https://open-api.naviprotocol.io/api/navi/user/rewards?userAddress=${e}&page=${(a == null ? void 0 : a.page) || 1}&pageSize=${(a == null ? void 0 : a.size) || 400}`, t = await fetch(r).then((c) => c.json());
|
|
840
|
+
return B({
|
|
841
841
|
data: t.data.rewards
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
844
|
);
|
|
845
|
-
async function
|
|
846
|
-
|
|
847
|
-
|
|
845
|
+
async function Me(e, a, r) {
|
|
846
|
+
var i;
|
|
847
|
+
const t = await w({
|
|
848
|
+
...r,
|
|
848
849
|
cacheTime: g
|
|
849
|
-
}), c = await
|
|
850
|
-
...
|
|
850
|
+
}), c = await S({
|
|
851
|
+
...r,
|
|
851
852
|
cacheTime: g
|
|
852
853
|
}), n = /* @__PURE__ */ new Map();
|
|
853
|
-
for (const
|
|
854
|
-
const { rewardCoinType:
|
|
855
|
-
for (const
|
|
856
|
-
n.has(
|
|
857
|
-
const
|
|
858
|
-
|
|
854
|
+
for (const u of a) {
|
|
855
|
+
const { rewardCoinType: l, ruleIds: d } = u;
|
|
856
|
+
for (const h of d) {
|
|
857
|
+
n.has(l) || n.set(l, { assetIds: [], ruleIds: [], amount: 0 });
|
|
858
|
+
const p = n.get(l);
|
|
859
|
+
p.assetIds.push(u.assetCoinType.replace("0x", "")), p.ruleIds.push(h), p.amount += u.userClaimableReward;
|
|
859
860
|
}
|
|
860
861
|
}
|
|
861
862
|
const o = [];
|
|
862
|
-
for (const [
|
|
863
|
-
const
|
|
864
|
-
(
|
|
863
|
+
for (const [u, { assetIds: l, ruleIds: d, amount: h }] of n) {
|
|
864
|
+
const p = c.find(
|
|
865
|
+
(v) => m(v.suiCoinType) === m(u)
|
|
865
866
|
);
|
|
866
|
-
if (!
|
|
867
|
-
throw new Error(`No matching rewardFund found for reward coin: ${
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
867
|
+
if (!p || !p.contract.rewardFundId)
|
|
868
|
+
throw new Error(`No matching rewardFund found for reward coin: ${u}`);
|
|
869
|
+
const y = p.contract.rewardFundId;
|
|
870
|
+
if (r != null && r.accountCap && !r.customCoinReceive)
|
|
870
871
|
throw new Error("customCoinReceive is required when accountCap is provided");
|
|
871
|
-
if (
|
|
872
|
-
let
|
|
873
|
-
|
|
872
|
+
if (r != null && r.customCoinReceive) {
|
|
873
|
+
let v;
|
|
874
|
+
r.accountCap ? v = e.moveCall({
|
|
874
875
|
target: `${t.package}::incentive_v3::claim_reward_with_account_cap`,
|
|
875
876
|
arguments: [
|
|
876
877
|
e.object("0x06"),
|
|
@@ -879,17 +880,17 @@ async function Ne(e, r, a) {
|
|
|
879
880
|
// Incentive V3 contract
|
|
880
881
|
e.object(t.storage),
|
|
881
882
|
// Protocol storage
|
|
882
|
-
e.object(
|
|
883
|
+
e.object(y),
|
|
883
884
|
// Reward fund
|
|
884
|
-
e.pure.vector("string",
|
|
885
|
+
e.pure.vector("string", l),
|
|
885
886
|
// Asset IDs
|
|
886
|
-
e.pure.vector("address",
|
|
887
|
+
e.pure.vector("address", d),
|
|
887
888
|
// Rule IDs
|
|
888
|
-
|
|
889
|
+
f(r.accountCap, e.object)
|
|
889
890
|
// Account capability
|
|
890
891
|
],
|
|
891
|
-
typeArguments: [
|
|
892
|
-
}) :
|
|
892
|
+
typeArguments: [u]
|
|
893
|
+
}) : v = e.moveCall({
|
|
893
894
|
target: `${t.package}::incentive_v3::claim_reward`,
|
|
894
895
|
arguments: [
|
|
895
896
|
e.object("0x06"),
|
|
@@ -898,32 +899,39 @@ async function Ne(e, r, a) {
|
|
|
898
899
|
// Incentive V3 contract
|
|
899
900
|
e.object(t.storage),
|
|
900
901
|
// Protocol storage
|
|
901
|
-
e.object(
|
|
902
|
+
e.object(y),
|
|
902
903
|
// Reward fund
|
|
903
|
-
e.pure.vector("string",
|
|
904
|
+
e.pure.vector("string", l),
|
|
904
905
|
// Asset IDs
|
|
905
|
-
e.pure.vector("address",
|
|
906
|
+
e.pure.vector("address", d)
|
|
906
907
|
// Rule IDs
|
|
907
908
|
],
|
|
908
|
-
typeArguments: [
|
|
909
|
+
typeArguments: [u]
|
|
909
910
|
});
|
|
910
|
-
const [
|
|
911
|
+
const [j] = e.moveCall({
|
|
911
912
|
target: "0x2::coin::from_balance",
|
|
912
|
-
arguments: [
|
|
913
|
-
typeArguments: [
|
|
913
|
+
arguments: [v],
|
|
914
|
+
typeArguments: [u]
|
|
914
915
|
});
|
|
915
|
-
if ((
|
|
916
|
-
if (!
|
|
916
|
+
if ((r == null ? void 0 : r.customCoinReceive.type) === "transfer") {
|
|
917
|
+
if (!r.customCoinReceive.transfer)
|
|
917
918
|
throw new Error("customCoinReceive.transfer is required");
|
|
918
919
|
e.transferObjects(
|
|
919
|
-
[
|
|
920
|
-
|
|
920
|
+
[j],
|
|
921
|
+
f(r.customCoinReceive.transfer, e.pure.address)
|
|
921
922
|
);
|
|
922
923
|
}
|
|
923
|
-
(
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
924
|
+
if ((r == null ? void 0 : r.customCoinReceive.type) === "depositNAVI") {
|
|
925
|
+
const U = T(p.totalSupplyAmount).shiftedBy(-9), G = T(p.supplyCapCeiling).shiftedBy(-27);
|
|
926
|
+
U.plus(h).isGreaterThan(G) && ((i = r == null ? void 0 : r.customCoinReceive.depositNAVI) != null && i.fallbackReceiveAddress) ? e.transferObjects(
|
|
927
|
+
[j],
|
|
928
|
+
e.pure.address(r.customCoinReceive.depositNAVI.fallbackReceiveAddress)
|
|
929
|
+
) : await x(e, p, j, r);
|
|
930
|
+
} else
|
|
931
|
+
o.push({
|
|
932
|
+
coin: j,
|
|
933
|
+
identifier: p
|
|
934
|
+
});
|
|
927
935
|
} else
|
|
928
936
|
e.moveCall({
|
|
929
937
|
target: `${t.package}::incentive_v3::claim_reward_entry`,
|
|
@@ -934,75 +942,75 @@ async function Ne(e, r, a) {
|
|
|
934
942
|
// Incentive V3 contract
|
|
935
943
|
e.object(t.storage),
|
|
936
944
|
// Protocol storage
|
|
937
|
-
e.object(
|
|
945
|
+
e.object(y),
|
|
938
946
|
// Reward fund
|
|
939
|
-
e.pure.vector("string",
|
|
947
|
+
e.pure.vector("string", l),
|
|
940
948
|
// Asset IDs
|
|
941
|
-
e.pure.vector("address",
|
|
949
|
+
e.pure.vector("address", d)
|
|
942
950
|
// Rule IDs
|
|
943
951
|
],
|
|
944
|
-
typeArguments: [
|
|
952
|
+
typeArguments: [u]
|
|
945
953
|
});
|
|
946
954
|
}
|
|
947
955
|
return o;
|
|
948
956
|
}
|
|
949
|
-
async function
|
|
950
|
-
const
|
|
951
|
-
...
|
|
957
|
+
async function Ue(e, a) {
|
|
958
|
+
const r = await w({
|
|
959
|
+
...a
|
|
952
960
|
});
|
|
953
961
|
return e.moveCall({
|
|
954
|
-
target: `${
|
|
962
|
+
target: `${r.package}::lending::create_account`,
|
|
955
963
|
arguments: []
|
|
956
964
|
});
|
|
957
965
|
}
|
|
958
966
|
export {
|
|
959
|
-
|
|
967
|
+
R as Address,
|
|
960
968
|
g as DEFAULT_CACHE_TIME,
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
969
|
+
ge as FlashLoanAssetConfig,
|
|
970
|
+
pe as IncentiveAPYInfo,
|
|
971
|
+
J as IncentivePoolInfo,
|
|
972
|
+
fe as IncentivePoolInfoByPhase,
|
|
973
|
+
me as OracleInfo,
|
|
974
|
+
P as PoolOperator,
|
|
975
|
+
ye as ReserveDataInfo,
|
|
976
|
+
Q as UserStateInfo,
|
|
977
|
+
ve as borrowCoinPTB,
|
|
978
|
+
Me as claimLendingRewardsPTB,
|
|
979
|
+
Ue as createAccountCapPTB,
|
|
980
|
+
x as depositCoinPTB,
|
|
981
|
+
ke as filterPriceFeeds,
|
|
982
|
+
Fe as flashloanPTB,
|
|
975
983
|
F as getAllFlashLoanAssets,
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
984
|
+
_e as getBorrowFee,
|
|
985
|
+
Be as getCoins,
|
|
986
|
+
w as getConfig,
|
|
987
|
+
he as getFees,
|
|
988
|
+
Se as getFlashLoanAsset,
|
|
989
|
+
Ie as getHealthFactor,
|
|
990
|
+
ee as getHealthFactorPTB,
|
|
991
|
+
Te as getLendingState,
|
|
992
|
+
C as getPool,
|
|
993
|
+
S as getPools,
|
|
994
|
+
re as getPriceFeeds,
|
|
995
|
+
te as getPythStalePriceFeedId,
|
|
996
|
+
Ae as getSimulatedHealthFactor,
|
|
989
997
|
D as getSimulatedHealthFactorPTB,
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
998
|
+
we as getStats,
|
|
999
|
+
Pe as getTransactions,
|
|
1000
|
+
Ee as getUserAvailableLendingRewards,
|
|
1001
|
+
De as getUserClaimedRewardHistory,
|
|
1002
|
+
Le as getUserTotalClaimedReward,
|
|
1003
|
+
Ve as liquidatePTB,
|
|
1004
|
+
je as mergeCoinsPTB,
|
|
997
1005
|
m as normalizeCoinType,
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1006
|
+
f as parseTxValue,
|
|
1007
|
+
Ce as repayCoinPTB,
|
|
1008
|
+
Re as repayFlashLoanPTB,
|
|
1009
|
+
Ne as summaryLendingRewards,
|
|
1010
|
+
$e as updateOraclePricesPTB,
|
|
1011
|
+
ae as updatePythPriceFeeds,
|
|
1012
|
+
A as withCache,
|
|
1013
|
+
_ as withSingleton,
|
|
1014
|
+
be as withdrawCoinPTB
|
|
1007
1015
|
};
|
|
1008
1016
|
//# sourceMappingURL=index.esm.js.map
|